Closed AstroRobin closed 1 year ago
I've implemented a version of this behaviour in https://github.com/MBravoS/splotch/commit/3c63750775cc54a7f8105b8695333c5705ab9249 for functions in plots_1d.py as these are the simplest.
This feature required the addition of the lims_handler()
function in base_func.py, which standardises the user's xlim/ylim values across all functions. It also required a slight adjustment to _plot_finalizer()
in which xlim
/ylim
can also have the state 'auto' — technically the user can also specify xlim='auto'
and I think in future this could be added to default Params fairly easily.
Side note, if one passes None into matplotlib's plt.set_xlim(None)
function, then nothing happens as one might expect. The new behaviour of xlim/ylim mimics this functionality, keeping it in line with user expectations.
Nice! It seems to be working nicely, so I think that once we converge on #66 I'll combine the changes in that issue, this, and those for #73 into one release.
Nice! It seems to be working nicely, so I think that once we converge on #66 I'll combine the changes in that issue, this, and those for #73 into one release.
Sounds like a good plan!
On a related note to #66 where
grid
was being overwritten by subsequent splotch calls, a similar thing occurs withxlim
/ylim
. Because settingxlim = None
triggers the limits to be set by autoscale, this forces the user to always specify their limits in their final splotch call. I think this is a bad design because whenever a new splotch call is made, this requires either rearranging function order, using thezorder
parameter or rewriting code.Instead, I think we take a similar approach to the solution for
grid
parameter, whereby we first check if this is the first plot call and if so then settingxlim = None
does indeed trigger autoscale and if not, then settingxlim = None
does not change limits, because those limits have probably already been set.This might create an edge case where the user initiates their first plot with
xlim=None
(i.e. autoscale), meaning that the auto limits are retained for all subsequent plot calls if the user continues withxlim=None
and perhaps this first plot call only covers a narrow range? I still think this is better than overwriting previously user-specified limits.