根据颜色代码:
https://m.wang1314.com/doc/webapp/topic/21084865.html
绘制多条线 y=sin(x)+1 y=sin(x)+2 y=sin(x)+3 ……y=sin(x)+7 ,每个颜色不同,点样式不同,线类型循环重复。
‘.’:点(point marker) ‘,’:像素点(pixel marker)
‘o’:圆形(circle marker) ‘v’:朝下三角形(triangle_down marker)
‘^’:朝上三角形(triangle_up marker) ‘<‘:朝左三角形(triangle_left marker)
‘>’:朝右三角形(triangle_right marker) ‘1’:(tri_down marker)
‘2’:(tri_up marker) ‘3’:(tri_left marker)
‘4’:(tri_right marker) ‘s’:正方形(square marker)
‘p’:五边星(pentagon marker) ‘*’:星型(star marker)
‘h’:1号六角形(hexagon1 marker) ‘H’:2号六角形(hexagon2 marker)
‘+’:+号标记(plus marker) ‘x’:x号标记(x marker)
‘D’:菱形(diamond marker) ‘d’:小型菱形(thin_diamond marker)
‘|’:垂直线形(vline marker) ‘_’:水平线形(hline marker)
我的答案:
import matplotlib.pyplot as plt
import numpy as np
colorlist=plt.cm.cool(np.linspace(0,1,7))
markers=["D","x","h",".","^",">","v"]
x=np.linspace(0,4*np.pi)
y=np.sin(x)+1
for i in range(0,7):
plt.plot(x,y+i,color=colorlist[i],linestyle=":",marker=markers[i])
plt.show()