【问题标题】:Odd Axis-Offset [duplicate]奇数轴偏移
【发布时间】:2014-05-05 10:50:55
【问题描述】:

下面的 python 代码生成了一个轴偏移非常奇怪的图形。这是错误还是预期行为?

我正在使用 Python 2.7 和 Matplotlib 1.3.1

import matplotlib.pyplot as plt
plt.plot([680e-3-20.0, 720e-3-20.0])

Y 轴范围为 -0.04 到 0,偏移量为 -1.928e1。我希望偏移量出现在轴标签中。

不幸的是,由于缺乏“声誉”,我无法发布剧情图片

期待您的 cmets。

【问题讨论】:

标签: python numpy matplotlib


【解决方案1】:

对我来说这看起来很正常,如果您不想要偏移量,可以使用以下命令禁用它:

fig, ax = plt.subplots()

ax.plot([680e-3 - 20.0, 720e-3 - 20.0])

ax.yaxis.set_major_formatter(mpl.ticker.ScalarFormatter(useOffset=False))

您也可以自己设置偏移量:

mpl.ticker.ScalarFormatter(useOffset=-20)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多