The diagrams I am generating have many lines, and I want to automatically use colors and markers to distinguish them.
I tried this:
for i,studyDframeTuple in enumerate(studyDframeTuples):
time = studyDframeTuple[1]['time']
error = studyDframeTuple[1]['Linf velocity error']
caseName = studyDirs[studyDframeTuple[0]]
ax.plot(time, error, marker = i % 12, label=caseName)
Which circulates marker
over (0,11). This kind of works, because for some reason marker < 12
. When I use marker = i % 20
, I get an error that makerstyle 12 is unknown
.
This is an example of the diagram I'm generating, it's not pretty, it's only used for checking test results:
The diagrams are resulting from tests with varying parameters, hence the need to iterate over all available colors, line styles and markers, to make sure that when I have 100 lines on a diagram, I can distinguish the ones that belong to exploded solutions (values like 1e15 on this plot).
How can I put all markers in matplotib in a list and iterate over them?
Edit:
I hacked a list of my own like this
mStyles = [".",",","o","v","^","<",">","1","2","3","4","8","s","p","P","*","h","H","+","x","X","D","d","|","_",0,1,2,3,4,5,6,7,8,9,10,11
]
But what when this changes? Can I obtain this list programmatically from matplotlib?
12 doesn't exist as marker value. You can have a dict of all existing markers using this :
from matplotlib.lines import Line2D
print(Line2D.markers)
Output:
{'.': 'point',
',': 'pixel',
'o': 'circle',
'v': 'triangle_down',
'^': 'triangle_up',
'<': 'triangle_left',
'>': 'triangle_right',
'1': 'tri_down',
'2': 'tri_up',
'3': 'tri_left',
'4': 'tri_right',
'8': 'octagon',
's': 'square',
'p': 'pentagon',
'*': 'star',
'h': 'hexagon1',
'H': 'hexagon2',
'+': 'plus',
'x': 'x',
'D': 'diamond',
'd': 'thin_diamond',
'|': 'vline',
'_':'hline',
'P': 'plus_filled',
'X': 'x_filled',
0: 'tickleft',
1: 'tickright',
2: 'tickup',
3:'tickdown',
4: 'caretleft',
5: 'caretright',
6: 'caretup',
7: 'caretdown',
8: 'caretleftbase',
9: 'caretrightbase',
10: 'caretupbase',
11: 'caretdownbase',
'None': 'nothing',
None: 'nothing',
' ': 'nothing',
'': 'nothing'}