How do I create space around the points I've plotted with matplotlib?
For example, in this plot, the bottom left point is cutoff by the axis, but I would like a little more space between the point and the axis.
import matplotlib.pyplot as plt x = [2**i for i in xrange(4,14)] y = [i**2 for i in x] plt.loglog(x,y,'ro',basex=2,basey=2) plt.xlim([0, 2**14]) # <--- this line does nothing plt.show()
In interactive mode, the
xlim line returns
(16.0, 16384), the old values instead of the new values I'm trying to set.
Zero can not be plotted on a loglog graph (log(0) = -inf). It is silently failing because it can not use 0 as a limit.
If you are looking for a general way to handle this problem and want to automatically adjust the limits of your plot (even without knowing anything of your data), you can also write a snippet inspired by this answer to a similar question.
Note that you will have to tweak the code a little bit and change it so it also do the job for the y axis.