| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
It seems like you've combined the logic of whether to display a tick (which is usually the job of a Locator subclass) with the logic of how to display a tick (which is usually the job of a Formatter subclass). Any reason why you didn't separate concerns like all the other Locator/Formatters? Other than that, I see this as very useful, though we'll have to determine whether or not it's a good idea to change the default behavior. |
Sorry, something went wrong.
|
@mdboom: For the case of log-scaled axis, it is nice to show all minor ticks to make it clear that the scaling is logarithmic, but we obviously do not want to label all minor ticks. The current default is show all minor ticks and label none. I had to combine them so that all minor ticks are shown, but not all of them labeled. I understand its a departure from how other Locator/Formatter work, but I did not see a different way to do it. EDIT: I could not find it, but is there any other Locator/Formatter where this is done (i.e., only some of the shown minor or major ticks are labeled)? |
Sorry, something went wrong.
|
@zblz: I understand the problem better now. I think it could lead to confusion that the formatter chooses not to format some ticks, particularly if using an explicit locator or something. However, as you say, I can't think of a better way right now. That's all the more argument to keep the default for log scales as something that formats everything. Let me think on it for a bit -- maybe there is a better way, perhaps by adding the ability to have separate locators for ticks and text... |
Sorry, something went wrong.
|
Separate locators would be ideal for this case, but it would increase the complexity of the tick logic in Axis. In addition, the process to change tick format and location is not the easiest thing for a user (needing additional imports from ticker, and discovering the names and options of the Locator/Formatter a bit difficult), so adding another Locator might complicate things even further. I don't really have a better option, though. By the way, I adapted this logic of not showing some labels from the only way I knew how to produce this previously, which was to use horrible, horrible ad-hoc labels like this: ax.xaxis.set_ticklabels([r'$2\times10^4$','','',r'$5\times10^4$','','','','',
r'$2\times 10^4$','','',r'$5\times10^4$','','','','',
r'$2\times 10^5$','','',r'$5\times10^5$','','','','',
],minor=True)
|
Sorry, something went wrong.
|
What if a locator could signal whether the location is intended for On Tue, Oct 6, 2015 at 1:58 PM, Victor Zabalza notifications@github.com
|
Sorry, something went wrong.
|
@WeatherGod: It sounds good, but I have no idea of how to even begin to implement that from a glance at ticker.py and axis.py. In Axis all ticks have an associated location and label, so if we dissociate the tick location and the label location we might need a lot of refactoring. |
Sorry, something went wrong.
|
If one works from the assumption that all ticklabels must have a tickline, On Tue, Oct 6, 2015 at 2:15 PM, Victor Zabalza notifications@github.com
|
Sorry, something went wrong.
|
The Formatter objects are called with the signature (tick_location, tick_number) where iirc tick_number is either None or the integer count of ticks along the axis (with possibly some off-by-one bugs due to a clipped left most tick). It may be possible to write a clever enough Formatter to take this into account. |
Sorry, something went wrong.
|
@tacaswell: But if whether we return a label depends on tick_number then we have the same problem as looking at the parent axis: the decision of whether to show a label is left to the Formatter rather than the Locator, which is what @mdboom objected to initially. |
Sorry, something went wrong.
|
Ok, I tried to move the print logic from the formatter to the locator following @WeatherGod's suggestion, and now the locator must return two arrays: the location for the ticks and whether each tick should be labeled. This means a change to all the __call__ functions of the locators: I have modified it only for LogLocator as a proof-of-concept, but they could also be wrapped so that if they only return one array, the second defaults to all True. |
Sorry, something went wrong.
|
re-milestoned this for 2.1 as this is not just changing some parameters. |
Sorry, something went wrong.
|
Change of mind right after pushing: I moved the logic on whether to show the labels to an different function than the __call__ so that this new function (show_tick_label) can be defined in the parent Locator class. In this way, locator classes that want labels on all their ticks don't have to be modified. |
Sorry, something went wrong.
|
To keep the focus of this PR, I have removed the functionality to plot (1e-1, 1e0, 1e1) as 0.1 1 10, because this should be covered by #4730 in LogFormatterMathtext. This allows LogFormatterSciNotation to be a subclass of LogFormatterMathtext with only the non-decade ticks formatted differently (and any changes to LogFormatterMathtext in #4730 will propagate here). |
Sorry, something went wrong.
|
Thanks. I think the separation of Locator/Formatter is much better now. One further refinement though -- I don't think we necessarily require that a Locator inherits from LocatorBase (matplotlib's built-in ones all do, but third-party ones may not). So we should be robust to the possibility that show_tick_label may not be present and handle the default behavior accordingly. |
Sorry, something went wrong.
|
Thanks. I'm happy to merge this once the test failure is resolved. |
Sorry, something went wrong.
|
Sorry, something went wrong.
|
Sorry, something went wrong.
|
We could consider the default change as part of 2.0. Not promising anything, but that's a good window of opportunity for it. |
Sorry, something went wrong.
|
I would like to suggest re-milestoning this (or the original issue, #4867), for 2.0. When round-number limits were the default, a log-scale axis would by default be expanded to initially cover at least one (integer) decade, and thus have at least two labeled ticks (at the two ends). With the switch to margins-based limits, it is now possible for axes to default to having no labels at all (e.g. semilogy([.2, .9])) which is (IMO) very bad. Edit: Changed the milestone, but feel free to discuss if you disagree. |
Sorry, something went wrong.
|
I have moved the logic back into the formatter classes, choosing to add it into LogFormatter rather than LogFormatterSciNotation as all log formatters could benefit from it (note though that all of them except for LogFormatterSciNotation have labelOnlyBase=True as default, so this change will not affect them if used with default parameters). I have also added back LogFormatterSciNotation as the default formatter for log-scaled axes. |
Sorry, something went wrong.
|
Getting a bunch of errors. Somehow, zeros are getting down into math.log(). Got some image comparison failures, too. |
Sorry, something went wrong.
|
I have fixed the error on symlog axes, which where sending values vmin <= 0 to math.log. I also updated the baseline images for the test_axes.log_scale test. |
Sorry, something went wrong.
|
The remaining error on matplotlib.tests.test_backend_ps.test_savefig_to_stringio_eps_afm will be fixed by PR #6898, so that should be merged before this PR. |
Sorry, something went wrong.
|
power-cycling to test against the latest master. |
Sorry, something went wrong.
|
This is passing and is milestoned for v2.0. I don't know who is the one to approve the remaining style changes. |
Sorry, something went wrong.
API: Changes to default log scale tick formatting
Reverts part of matplotlib#5161 original commit merged to master as 947e6eb the merge was backported to v2.x as fb45c4a
This partly restores the functionality that was added in PR matplotlib#5161 and partly removed in matplotlib#7000. The "partly" is because now the labeling of minor log ticks is turned on only when numdecs (the axis range in powers of the log base) is less than or equal to one, rather than 3. This also fixes a bug that was causing double labeling with a base of 2; minor ticks were coinciding with major ticks, and both were being labeled.
| Back | FazBrowse Home | New Git URL |
Following #4730 and #4867, this is a proposal to change the defaults for the upcoming 2.0 release regarding the default tick label formatting for log-scaled axes. This is not a finished PR, but mean to initiate discussion on whether this is desired as default (if not I still think a similar thing could be worth having as an option).
Example of this formatter in action:

The main motivation is to improve readability of the axis ticks when log-scaled axis are zoomed-in to less than a few decades, which under the current Formatters leaves only very few labels in the axis. Note that this does not change the formatting whenever more than 3 decades are spanned by the axis view limits.