I have a problem with plotting in matplotlib
, but the question may be more about handling numpy
arrays than about the plotting itself - a solution in matplotlib would perhaps be more desirable!
The problem is this: I have two ndarrays, xvals
and yvals
of shape (1000,), to be interpreted as fitted x and y coordinates (they are supposed to be centered around some value). Some elements (but not very few!) have extremely large absolute values compared to the others (by a factor 1000 or larger). The reason I can't set the axes to some fixed value is that mean(xvals)
and mean(yvals)
and their standard deviation varies between the plots quite a bit.
I want to do a 2d plot of the points with something like plt.plot(xvals, yvals, '.')
, and it is important for me to set the axes automatically so that one can see the main distribution of points clearly. The reason that is has to be done automatically is that I'm doing ~100 plots and must be able to name and change things in the plots repeatedly.
I have already tried to use plt.axis([mean(xvals) - k * std(xvals), mean(xvals) + k * std(xvals), mean(yvals) - k * std(yvals), mean(yvals) + k * std(yvals)])
, trying out different values of k
, but none seems to work for all my plots.
Here are two pictures, showing (1) what I get (without using axis()
at all, and (2) what I roughly would like to have outputted:
I hope I have provided enough information, please tell me otherwise and I will try to provide it!