跳至內容

File:Rosenbrock function.svg

頁面內容不支援其他語言。
這個檔案來自維基共享資源
維基百科,自由的百科全書
    原始檔案 (SVG 檔案,表面大小:720 × 540 像素,檔案大小:2.28 MB)


    摘要

    描述
    English: Rosenbrock function over ℝ2. The Python code needs at least Matplotlib v0.99. The MATLAB/Octave code was tested with GNU Octave 4.2.2 and MATLAB R2016a.
    Español: Funció de Rosenbrock definida sobre ℝ2.
    日期
    來源 自己的作品
    作者 Morn the Gorn
    Python source
    InfoField
    click to expand
    from mpl_toolkits.mplot3d import Axes3D
    from matplotlib.colors import LogNorm
    import matplotlib.pyplot as plt
    import numpy as np
    
    fig = plt.figure()
    ax = Axes3D(fig, azim=-128, elev=43)
    s = .05
    X = np.arange(-2, 2.+s, s)
    Y = np.arange(-1, 3.+s, s)
    X, Y = np.meshgrid(X, Y)
    Z = (1.-X)**2 + 100.*(Y-X*X)**2
    # ax.plot_surface(X, Y, Z, rstride=1, cstride=1, norm = LogNorm(),
    #                 cmap="viridis")
    # Without using `` linewidth=0, edgecolor='none' '', the code may produce a
    # graph with wide black edges, which will make the surface look much darker
    # than the one illustrated in the figure above.
    ax.plot_surface(X, Y, Z, rstride=1, cstride=1, norm=LogNorm(),
                    linewidth=0, edgecolor='none', cmap="viridis")
    
    # Set the axis limits so that they are the same as in the figure above.
    ax.set_xlim([-2, 2.0])                                                       
    ax.set_ylim([-1, 3.0])                                                       
    ax.set_zlim([0, 2500]) 
    
    plt.xlabel("x")
    plt.ylabel("y")
    plt.savefig("Rosenbrock function.svg", bbox_inches="tight")
    
    plt.show()
    
    MATLAB/Octave source
    InfoField
    click to expand
    clear all;
    close all;
    hfig = figure(1);
    
    s = 0.05;
    X = [-2 : s : 2+s];
    Y = [-1 : s : 3+s];
    [X, Y] = meshgrid(X, Y);
    Z = (1-X).^2 + 100*(Y-X.^2).^2;
    
    % Use log scale of Z for a batter usage of the color spectrum  
    minZ = min(Z(:));  
    maxZ = max(Z(:));
    C = minZ + (maxZ-minZ).*log(1+Z-minZ)./log(1+maxZ-minZ); 
    % See
    % http://stackoverflow.com/questions/5073865/how-to-color-surface-with-stronger-contrast
    % for how to color a surface with a even stronger contrast.   
    % The method is as follows:
    %C = Z;
    %[~, index] = sort(C(:));
    %C(index) = 1 : numel(index);
    
    colormap(jet);
    surf(X, Y, Z, C, 'EdgeColor', 'none', 'LineStyle', 'none');
     
    axis([-2, 2, -1, 3, 0, 2500]);
    xlabel('x', 'fontsize', 18);
    ylabel('y', 'fontsize', 18);
    zlabel('f', 'fontsize', 18);
     
    % Note that the `-dsvg' option is only supported for Simulink systems
    print(hfig, '-dsvg', 'rosenbrock');
    % To produce eps and pdf, use the following code. Notice that `epstopdf' may not work on Windows. 
    print(hfig, '-depsc', 'rosenbrock');
    system('epstopdf rosenbrock.eps');
    

    授權條款

    Public domain 我,此作品的版權所有人,釋出此作品至公共領域。此授權條款在全世界均適用。
    這可能在某些國家不合法,如果是的話:
    我授予任何人有權利使用此作品於任何用途,除受法律約束外,不受任何限制。

    說明

    添加單行說明來描述出檔案所代表的內容

    在此檔案描寫的項目

    描繪內容

    創作作者 中文 (香港) (已轉換拼寫)

    沒有維基數據項目的某些值

    作者姓名字串 中文 (香港) (已轉換拼寫):Morn the Gorn
    維基媒體使用者名稱 繁體中文 (已轉換拼寫):Morn the Gorn

    版權狀態 中文 (香港) (已轉換拼寫)

    檔案來源 中文 (臺灣) (已轉換拼寫)

    上傳者的原創作品 繁體中文 (已轉換拼寫)

    多媒體型式 繁體中文 (已轉換拼寫)

    image/svg+xml

    創作所用軟件 繁體中文 (已轉換拼寫)

    Matplotlib 繁體中文 (已轉換拼寫)

    客體的角色 中文 (香港) (已轉換拼寫):plotting library 英文
    客體的角色 中文 (香港) (已轉換拼寫):自由及開放源碼軟件 中文 (香港) (已轉換拼寫)
    客體的角色 中文 (香港) (已轉換拼寫):Python函式庫 繁體中文 (已轉換拼寫)

    檔案歷史

    點選某个日期/時間檢視對應時刻的檔案。

    日期/時間縮⁠圖大小用戶備⁠註
    目前2020年6月5日 (五) 01:19於 2020年6月5日 (五) 01:19 版本的縮圖720 × 540​(2.28 MB)ZhangzkThe original colour looks much better (Reverted to version as of 11:52, 6 April 2010 (UTC))
    2018年8月15日 (三) 15:25於 2018年8月15日 (三) 15:25 版本的縮圖603 × 459​(1.21 MB)NicoguaroChange colormap to viridis. Smaller file.
    2010年4月6日 (二) 11:52於 2010年4月6日 (二) 11:52 版本的縮圖720 × 540​(2.28 MB)Morn{{Information |Description={{en|1=Rosenbrock function}} |Source={{own}} |Author=Morn the Gorn |Date=2009-09-04 |Permission= |other_versions= }} Category:Functions in two variables

    全域檔案使用狀況

    以下其他wiki使用了這個檔案:

    詮釋資料