您可以定义[自定义
破折号:
import matplotlib.pyplot as pltline, = plt.plot([1,5,2,4], '-')line.set_dashes([8, 4, 2, 4, 2, 4]) plt.show()
[8, 4, 2, 4, 2, 4]means
- 8 points on, (dash)
- 4 points off,
- 2 points on, (dot)
- 4 points off,
- 2 points on, (dot)
- 4 points off.
@Achim noted you can also specify the
dashesparameter:
plt.plot([1,5,2,4], '-', dashes=[8, 4, 2, 4, 2, 4])plt.show()
produces the same result shown above.



