nc-time-axis
nc-time-axis copied to clipboard
Control max number of ticks
Currently, the max number of ticks is set to 4 (on this line). This is a bit restrictive.
It would be nice if the user had control over the number of ticks, perhaps through the use of some kind of set_max_ticks
method.
I think this would be relatively easy to implement. I'm experienced with python but not with GitHub so I've been toying around with how to contribute a solution to this. In the mean time, if anyone else wants a work around for modifying the number of ticks, here's an example which sets the max number to 7. You can also modify other parameters of matplotlib's MaxNLocator this way.
ax.xaxis.get_major_locator()._max_n_locator.set_params(nbins=7)
Note this only works if the resolution is not daily. If you have daily resolution along the time axis, use
ax.xaxis.get_major_locator()._max_n_locator_days.set_params(nbins=7)
Really it would be great if support is implemented for the set_params() method. This information could be passed onto the MaxNLocator as I am doing here. Then you could make your adjustments using the ax.locator_params
from matplotlib. I'm working on such a solution but do not have much time to dedicate, and so I'm leaving this idea here to help collective progress.
@SciTools/peloton just reviewing this. @sjsmith757 is there any chance of your submitting an attempt at this ? Otherwise we might have to close this down.