我正在 PyX 中绘制条形图,但命令与连续图不同。
我有这样的东西:
Q1) 如何在 x 轴上只打印一些(例如偶数 2, 4, 6, ...)?
Q2) 如何为 y 轴指定轴标签名称?
这是一个最小的代码(来自here)
g = graph.graphxy(width=8, x=graph.axis.nestedbar())
g.plot([graph.data.file("minimal.dat", xname="$0, 0", y=2),
graph.data.file("minimal.dat", xname="$0, 1", y=3)],
[graph.style.bar()])
g.writeEPSfile("compare")
from pyx import *
subaxes = {i+1: graph.axis.bar(dist=0, title=str(i+1) if i%2 else None,
painter=graph.axis.painter.bar(nameattrs=None), linkpainter=None)
for i in range(12)}
g = graph.graphxy(width=8, x=graph.axis.nestedbar(subaxes=subaxes, painter=graph.axis.painter.bar(nameattrs=None)), y_title="y axis title")
g.plot([graph.data.file("minimal.dat", xname="$0, 0", y=2),
graph.data.file("minimal.dat", xname="$0, 1", y=3)],
[graph.style.bar()])
g.writeEPSfile("compare")
Q1)条形轴始终使用画家显示的名称的子轴名称。目前没有办法解决这个问题。但是,您可以使用子轴的标题,并自己提供正确的标题,如解决方案中所示。
另请注意,条形轴不使用数值,也不使用伙伴来生成刻度和标签。
Q2)如果我正确理解你的问题,只需为 y 轴设置一个轴标题即可。