小编gla*_*anz的帖子

Matplotlib:如何制作由点(圆圈)组成的虚线?

我有两个平滑的依赖 y1(x) 和 y2(x),其中 x 的分布不规则。我希望用虚线 ( linestyle = ':')描述这些依赖关系。我现在得到的* .pdf文件显示在这里

这是代码:

import matplotlib.pyplot as plt

fig, ax = plt.subplots()

x  = [0, 1, 2,  3,  5,  7, 13, 14]
y1 = [3, 5, 6,  8,  7,  6,  9, 10]
y2 = [1, 7, 8, 10, 14, 18, 20, 23]

ax.plot(x, y1, 
        linestyle = ':',
        linewidth = 4,
        color = 'Green')

ax.plot(x, y2, 
        linestyle = ':',
        linewidth = 4,
        color = 'Blue')

ax.set_ylabel('y(x)')
ax.set_xlabel('x')

plt.savefig("./test_dotted_line.pdf")
Run Code Online (Sandbox Code Playgroud)

我玩过dashes …

python matplotlib

4
推荐指数
2
解决办法
8627
查看次数

标签 统计

matplotlib ×1

python ×1