我需要一种方法来制作matplotlib linestyle'---'。 3'的' - '。
character description
'-' solid line style
'--' dashed line style
'-.' dash-dot line style
':' dotted line style
etc.
我可以在列表中看到' - '和' - ',但在右上方,我的传奇出现了“ - 红色虚线”(如果我写linestyle =' - ')。我想在我的传奇盒子上点上“---红色虚线”
有什么方法可以让传说显示三个破折号? 这就是我正在做的事情。
import matplotlib.pyplot as mpt
def main():
mpt.title("hi")
mpt.xlabel("x axis")
mpt.ylim([0,50])
mpt.xlim([0,10])
mpt.ylabel("y axis")
mpt.plot([1,2,3,4],[2,3,4,5],'r', linestyle = '???????')
mpt.legend(["red dotted line"])
mpt.show()
main()
答案 0 :(得分:1)
使用mpt.legend(handlelength=3)
和linestyle='--'
mpt.plot([1,2,3,4],[2,3,4,5],'r', linestyle='--')
mpt.legend(["red dotted line"], handlelength=3)