Often, I'll have a list of pairs I want to plot, that goes over some broad range. For example:
a = Table[{x, x^5}, {x, -5, 5, .1}];
ListPlot[a]
However, I'll really only want to plot a subset of those points, knowing the sub-domain (i.e., x values, in this case, -2 to 2) I want to plot, but not the range of that sub-domain (the y values). Similarly, I want ListPlot to automatically scale the vertical axis, within this subset. However, if I do:
ListPlot[a, PlotRange -> {{-2, 2}, Automatic}]
I get:
So it's obviously just using the auto range for the full data set still. This makes some sense, because technically I'm still passing it the whole set. So I know one solution is to first cleanse that data set. But at this point it seems like ListPlot could also figure out the points I actually want plotted. Is there a way to make it do this?
ListPlot@Select[a, -2 < #[[1]] < 2 &]
$\endgroup$