0

我在 Pyx 模块中使用 Python 绘制:

 g = graph.graphxy(width=8,
              x=graph.axis.linear(min=0, max=2),
              y=graph.axis.linear(min=0, max=2),
              )

 g.plot([graph.data.function("x(y)=y**4")],
   [graph.style.line([style.linestyle.dotted])])

 g.writeEPSfile("plot")

如何更改虚线中点之间的间距?

4

1 回答 1

0

只需使用您自己的线型设置:

c = canvas.canvas()
c.stroke(path.line(0, 0, 10, 0), [style.linestyle(style.linecap.round, style.dash([0, 2]))])
c.stroke(path.line(0, -1, 10, -1), [style.linestyle(style.linecap.round, style.dash([0, 4]))])
c.stroke(path.line(0, -2, 10, -2), [style.linestyle(style.linecap.round, style.dash([0, math.pi])), style.linewidth(0.1)])
c.writePDFfile(page_bboxenlarge=1)

第一行与 style.linestyle.dotted 相同,第二行使用点之间距离的两倍,第三行显示一个浮点数作为距离并改变线宽。请注意,线宽定义了点的大小,也改变了点之间的距离,因为破折号的值是由线宽缩放的。虚线由虚线长度为零的虚线构建,并style.linecap.round作为线帽设置。

请注意,首先应用线宽(归属顺序......没有很好的记录)。

于 2018-06-02T03:01:51.690 回答