I am trying to plot a bunch of data points (many thousands) in Python using matplotlib so I need each marker to be very small and precise. How do I get the smallest most simple marker possible? I use this command to plot my data:
matplotlib.pyplot( x , y ,'.',markersize=0.1,linewidth=None,markerfacecolor='black')
Then I can look at it either with
pl.show() and then save it. Or directly use
plt.savefig('filename.ps') in the code to save it. The problem is this: when I use
pl.show() to view the file in the GUI it looks great with small tiny black marks, however when I save from the
show() GUI to a file or use directly
savefig and then view the
ps I created it looks different! Each marker has gained a little blue halo around it (as if it started at each point to connect them with the default blue lines, but did not) and the style is all wrong. Why does it change the style when saved? How do I stop python from forcing the style of the markers? And yes I have looked at some alternative packages like CairoPlot, but I want to keep using matplotlib for now.
Update: It turns out that the save to PNG first makes the colors turn out okay, but it forces a conversion of the image when I want to save it again as a
.ps later (for inclusion in a PDF) and then I lose quality. How do I preserve the vector nature of the file and get the right formatting?
For nice-looking vectorized output, don't use the
'.' marker style. Use e.g.
'o' (circle) or
's' (square) (see
help(plot) for the options) and set the
markersize keyword argument to something suitably small, e.g.:
plot(x, y, 'ko', markersize=2) savefig('foo.ps')
'.' (point) produces less nice results could be construed as a bug in matplotlib, but then, what should "point" mean in a vector graphic format?