Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Description
Enhancement discussion
Often it is desirable to have a second x or y scale on an axes with a different scale than the primary x/y axis; think frequency and period on the xaxis of a power spectrum, or date and datenum for a time series. (just assuming the x-axis for now:) Generally it'd be the same size as the existing xaxis, but would be offset vertically, have its own locator, formatter, and xlabel. it would update as the data is zoomed through, and be slave to the parent xaxis
It appears folks most often do this with twiny (i.e.https://stackoverflow.com/questions/10514315/how-to-add-a-second-x-axis-in-matplotlib) but there is nothing to make the axes continue to have the same x-limits under interactive viewing, and no simple way to have the new axes have a different scale.
The enhancement here would be to add something like:
secaxis = ax.secondary_xaxis(loc='top', convert=5, label='Boo')
wheresecaxis
is either an axis object or an axes.loc
would be something like"top", "bottom", "above", "below", float
where "above" and "below" means that it goes above or below any existing axis, and the float is a hard-set axes fraction (like theset_position
ofspine
now).convert
would be a conversion factor: a float would just be a multiplier, or a function could be passed that converts x to xnew. No doubt there could be a way to make this work with units instead, but...
How to impliment
As discussed in#10961@efiring thought implimenting as an axes with shrunk and hidden unused dimensions would be good.
I'd advocate an axis object so that the logical organization makes more sense. i.e. this would be a child of the original axes, and would be included as one of the axes decorators. But, I haven't thought through all the implimentation details yet.