【发布时间】:2019-04-29 10:37:46
【问题描述】:
考虑下面PyX plot
如何排列图形键,而不是一个 4 个条目的 verticle 列表,而是并排有 2 个列表(每个 2 个条目)?
我的意思是,而不是键:
x = y^4,
x = y^2,
x = y,
y = x^4,
有钥匙:
x = y^4, x = y
x = y^2, y = x^4
代码如下:
from pyx import *
g = graph.graphxy(width=8,
x=graph.axis.linear(min=0, max=2),
y=graph.axis.linear(min=0, max=2),
key=graph.key.key(pos="br", dist=0.1))
g.plot([graph.data.function("x(y)=y**4", title=r"$x = y^4$"),
graph.data.function("x(y)=y**2", title=r"$x = y^2$"),
graph.data.function("x(y)=y", title=r"$x = y$"),
graph.data.function("y(x)=x**4", title=r"$y = x^4$")],
[graph.style.line([color.gradient.Rainbow])])
g.writePDFfile("change")
【问题讨论】:
-
在 matplotlib 中,您可以在
plt.legend命令中简单地使用ncol=2。例如,阅读this。 -
@Sheldore,谢谢 - 我刚刚在 PyX 中尝试过,但 "ncol=2" 没有用 :-(
标签: python matplotlib plot pyx