【问题标题】:rescale and normalize x axis numbers in python3.2 and matplotlib在 python3.2 和 matplotlib 中重新缩放和标准化 x 轴数
【发布时间】:2014-03-14 20:06:32
【问题描述】:

我正在使用 python 3.2 和 matplotlib。

x 轴的个数在 0 到 1000000 之间。

在我的情节中,x 轴的数字很长并且相互重叠。

我想在 0 到 10 之间重新缩放和标准化它们,并在 x 轴周围显示单位(例如 10^6)。

我该怎么做?

任何帮助将不胜感激。

【问题讨论】:

    标签: python python-3.x windows-7 matplotlib


    【解决方案1】:

    使用set_powerlimits():

    import pylab as pl
    x = np.linspace(0, 1000000, 100)
    y = x * 2
    
    pl.plot(x, y)
    ax = pl.gca()
    xaxis = ax.xaxis
    xaxis.major.formatter.set_powerlimits((0, 4))
    

    【讨论】:

      猜你喜欢
      • 2015-09-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-10
      • 1970-01-01
      • 2021-05-30
      • 1970-01-01
      • 2020-12-03
      相关资源
      最近更新 更多