as user1127062 suggests, maybe your code is ok.
If you donโt need the plot to be interactive, save it as svg
If you run:
data = numpy.random.randn(10000) pylab.hist(data,300) pylab.savefig(fileName+'.svg',format='svg')
you will see the alias of the pixels (in bandwidth) in the picture window, but it got into the svg file.
The cairo backend seems to do the best job of saving png files if svg is incompatible with what you are doing. They look as good as a svg screenshot.
You can switch the backend by running.
import matplotlib
raw "cairo" does not support show()
, so you cannot use it interactively or display a graph directly from the program.
The GTKCairo backend has the best of both worlds, but is not included in the default installation (at least not in what I got with sudo apt-get install matplotlib
)
If you are using Ubuntu, I think all you have to do to get it working is to install gtk and recompile matplotlib:
sudo apt-get install git-core python-gtk2-dev git clone git://github.com/matplotlib/matplotlib.git cd matplotlib sudo python setup.py install
You can check which of the backends is active:
matplotlib.get_backend()
You can automatically load your favorite backend by searching for your matplotlibrc
file, I found it in:
/usr/local/lib/python2.7/dist-packages/matplotlib/mpl-data/matplotlibrc
mdaoust
source share