【问题标题】:Matplotlib log scale formattingMatplotlib 对数刻度格式
【发布时间】:2015-09-29 06:39:26
【问题描述】:

matplotlib 为轴指定对数刻度时,标记该轴的默认方法是使用 10 次方的数字,例如。 10^6。有没有一种简单的方法可以将所有这些标签更改为例如:1、5、10、20?

【问题讨论】:

    标签: python matplotlib axis-labels


    【解决方案1】:

    发现于this thread

    import matplotlib.pyplot as pl
    from matplotlib.ticker import ScalarFormatter
    
    fig = pl.figure()
    ax = fig.add_subplot(111)
    
    ax.set_xscale('log')
    ax.set_xticks([1,2,5,10])
    ax.get_xaxis().set_major_formatter(ScalarFormatter())
    ax.set_xlim([1., 10.])
    

    【讨论】:

      猜你喜欢
      • 2014-03-22
      • 2017-08-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多