【发布时间】:2011-09-12 11:03:33
【问题描述】:
我使用 matplotib 的 Axes API 来绘制一些图形。我绘制的其中一条线代表理论预期线。它在原始 y 和 x 限制之外没有任何意义。我想要的是 matlplotlib 在自动缩放限制时忽略它。我以前做的是检查当前限制是多少,然后绘制并重置限制。问题是,当我绘制第三张图时,限制与理论线一起重新计算,这确实扩大了图表。
# Boilerplate
from matplotlib.figure import Figure
from matplotlib.backends.backend_pdf import FigureCanvasPdf
from numpy import sin, linspace
fig = Figure()
ax = fig.add_subplot(1,1,1)
x1 = linspace(-1,1,100)
ax.plot(x1, sin(x1))
ax.plot(x1, 3*sin(x1))
# I wish matplotlib would not consider the second plot when rescaling
ax.plot(x1, sin(x1/2.0))
# But would consider the first and last
canvas_pdf = FigureCanvasPdf(fig)
canvas_pdf.print_figure("test.pdf")
【问题讨论】:
-
是否可以调整绘制每条曲线的顺序? “理论上的”情节能否出现在最后?
-
@Yann ,我不能保证情节的顺序。这就是为什么在绘图之前保留 xlim 和 ylim 没有帮助。
标签: python matplotlib