-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
setting log major ticks leaves interfering minor tick labels #8386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This has nothing to do with contourf; the reason the the two axes in the example have different y-axis behavior is that their ylims differ. I don't think this is a bug at all; it is an inevitable consequence of the design change in v2.0, in which we label some or all minor ticks on a log scale when less than one decade is shown. The underlying design problem is that the locating and formatting of major and minor ticks is handled independently, so when coordination is needed it must be done manually. In this case that means explicitly setting the minor formatter. Even that is not really enough, though, because it still leaves a minor tick landing on a major tick, which is unintended and not always invisible. |
@efiring thanks for the insight. feel free to remove the bug label if you think that's appropriate |
I'm going to close this. We are overwhelmed with open issues. Leaving this one open is not going to make it any more likely that we will make the major changes required to solve the fundamental underlying design problem. |
@efiring: The problem, though, is that the behaviour is different in
plt.plot. Also, if the minor minor tick marks are labelled as shown, then they should not overlap. This does not seem to be an appropriate default and should maybe at some point be addressed, don't you think so?
With this default and formatting the minor axis labels, this is what I tried first,
ax1.get_yaxis().set_minor_formatter(StrMethodFormatter('{x:.0f}'))
I get overlapping minor labels...
@phobson Thank you for the work around!!
|
@fabrivelas, the behavior is the same in plt.plot when the axis limits are the same. The axis limits differ in your example because image-like artists set tight limits, while functions like The new default was chosen after careful consideration, and with a clear rationale: it solves a problem in a very common use case in which no modifications to the default values are made. In your case you are overriding defaults, so it is not unreasonable that you need to override the minor formatter and/or locator at the same time. We are thinking about a major overhaul that would provide an API in which there would be better coordination between major and minor ticks and formats, but if this is done at all, it will be quite some time in the future. The overlapping of major and minor labels is a consequence of each label being positioned relative to its tick marker; I think this is essential, and must not be changed. |
@efiring: Thank you for the clarification. I was not aware that plot (function) was behaving differently from contourf (artist). I might be a bit obstinate, but when I change the default format for the major tick labels, should then not the format also change (automatically) for the minor tick labels, if they appear automatically? Or in stated differently: I have to be aware that the behaviour changes when only a decade is plotted because suddenly there appear differently formatted labels. |
The difference between plot and contourf is not between functions and artists, but between the types of things being drawn. Contour, pcolormesh, imshow fill a frame; one rarely wants a margin. Line plots, scatter plots, etc. often benefit from a margin, so in the 2.0 style change we adopted the use of a small margin for them by default. See my earlier comment about a possible major overhaul. In the meantime, you are stuck with mpl as it is and as it evolves, and yes, you have to be aware of the good and the bad aspects of the way it works. |
@efiring Thank you again. It would be nice though, if the automatically included tick labels had the same format as the major tick labels ;-) I actually like the new default i.e. the choice of the positions of the minor tick labels automatically included... |
Bug report
contourf produces wrongly formatted plot labels for logarithmic plots when there is only one order of magnitude or less of range of data (eg. 10 to 100 or 100 to 1000).
Code for reproduction
Actual outcome

Using matplotlib 2.0.0 the labelling of the y-axis of the contour plot is messed up compared to the y-axis of the line plot.
Remark: The default color map was used.
Expected outcome
Using matplotlib 1.5.1 the labelling of the y-axis of the contour plot is as beautiful as the labelling of the y-axis of the line plot.

Remark: The default color map was used.
Matplotlib version
matplotlib 2.0.0 (installed using pip)
python 3.6.1 (installed using brew)
macos
The text was updated successfully, but these errors were encountered: