【问题标题】:Python Pyx plot: changing spacing between dots in dotted linePython Pyx plot:改变虚线中点之间的间距
【发布时间】:2018-05-31 09:42:03
【问题描述】:

我在 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")

如何改变虚线点间距?

【问题讨论】:

    标签: python plot pyx


    【解决方案1】:

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

    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 作为线帽设置。

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

    【讨论】:

      猜你喜欢
      • 2021-08-02
      • 1970-01-01
      • 2020-06-24
      • 1970-01-01
      • 2017-07-06
      • 1970-01-01
      • 2018-04-04
      • 2021-05-01
      • 1970-01-01
      相关资源
      最近更新 更多