【问题标题】:Mark a specific level in contour map on matplotlib在 matplotlib 上的等高线图中标记特定级别
【发布时间】:2014-06-26 06:27:22
【问题描述】:

谁能给我一个如何在等高线图中标记特定级别的示例? 我想在此图中标记为黑线的级别:

我正在使用以下代码:

plt.figure()

CS = plt.contour(X, Y,log_mu,levels = [np.log10(5e-8),np.log10(9e-5)])
CS = plt.contourf(X, Y,log_mu)
CB = plt.colorbar(CS, shrink=0.8, extend='both')

plt.xscale('log')
plt.yscale('log')

plt.show()

而这个特定情节的数据可以在这里获得dpaste data for contour plot

【问题讨论】:

    标签: python matplotlib contour


    【解决方案1】:

    查看 matplotlib 库中的 this example 以了解等高线图功能。通过修改脚本中的级别,以及更改一些引用,会导致:

    plt.figure()
    
    CS = plt.contour(X, Y,log_mu,levels = [-7,-8],
                     colors=('k',),linestyles=('-',),linewidths=(2,))
    CSF = plt.contourf(X, Y,log_mu)
    plt.clabel(CS, fmt = '%2.1d', colors = 'k', fontsize=14) #contour line labels
    CB = plt.colorbar(CSF, shrink=0.8, extend='both')
    
    plt.xscale('log')
    plt.yscale('log')
    
    plt.show()
    

    【讨论】:

      猜你喜欢
      • 2018-07-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-04
      • 1970-01-01
      • 1970-01-01
      • 2013-08-14
      • 1970-01-01
      相关资源
      最近更新 更多