Join GitHub today
Secondary_y axis default limit (top) & bound (upper) not matching ticks #5560
I raised this on SO see link here. The comments there provide clarity on this issue.
Started seeing this after I upgraded to 1.5 - but not sure if this is an issue just for 1.5.
The following code shows that, with the default settings, the secondary (RHS) y axis' max tick does not equal to its
It doesn't feel like a bug, but it could be a behaviour that is nice to have, for example, when I need to match the grid lines for both axes manually by making sure that the chart actually shows the same number of ticks on both axes. At the moment RHS axis has 8 ticks but the chart only shows 7 of them by default. You can fix this with
Output prints, Note:
Updated code above to use
Managed to upload the chart. Note that the RHS axis (variable
This can be inconvenient sometimes. For example, one way to align the grid lines from both axes is to make sure both axes have the same number of ticks. (Welcome other suggestions!) The no. of ticks for RHS in the chart displayed do not match
Hope this helps to clarify. Thanks.
So the minimal example is:
x = [x + 0.5 for x in range(10)] z = [(y+0.0)/10-0.004 for y in range(10)] fig, ax = plt.subplots() ax2 = ax.twinx() ax.plot(x) ax2.plot(z, c='r') ax.grid(True, axis='y') ax2.grid(True, axis='y')
The way that mpl is implemented underneath the tick locators, the tick formatters, and the axis limits are implemented independently (and that is definitely a feature).
Thanks for the explanation. What's the benefit of allowing
Also when you say that it is a feature to implement tick locator/formatter/axis limits independently, what are the benefits to do so? Just trying to understand the essence of its design.
The primary benefit, IIRC, is to better handle situations involving
On Wed, Nov 25, 2015 at 5:47 PM, esvhd firstname.lastname@example.org wrote: