As I need to plot many curves in a single figure, I need many different types of markers. Sometimes the number of the default markers are not enough, so it would be nice if the user could customize the marker types.
According to the document page (http://matplotlib.sourceforge.net/api/artist_api.html#matplotlib.lines.Line2D.set_marker), it is possible to use mathtext as the marker. However, it did not work in my case.
plot(x, y, marker='$||$') # To use two vertical lines as the marker.
The error message is like this:
File "/usr/lib/pymodules/python2.6/matplotlib/axes.py", line 3432, in plot
for line in self._get_lines(*args, **kwargs):
File "/usr/lib/pymodules/python2.6/matplotlib/axes.py", line 311, in _grab_next_args
for seg in self._plot_args(remaining, kwargs):
File "/usr/lib/pymodules/python2.6/matplotlib/axes.py", line 298, in _plot_args
seg = func(x[:,j%ncx], y[:,j%ncy], kw, kwargs)
File "/usr/lib/pymodules/python2.6/matplotlib/axes.py", line 248, in _makeline
self.set_lineprops(seg, **kwargs)
File "/usr/lib/pymodules/python2.6/matplotlib/axes.py", line 191, in set_lineprops
func(val)
File "/usr/lib/pymodules/python2.6/matplotlib/lines.py", line 804, in set_marker
self._markerFunc = self._markers[marker]
KeyError: '$||$'
The matplotlib version is:
m开发者_如何学运维atplotlib.__version__
'0.99.1.1'
I also tried plot(x, y, marker=r'$||$')
, which does not work either.
Have you set text.usetex
in your matplotrc file? You also need to use the right output backend, such as Postscript or PDF.
精彩评论