Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add additional minor labels in log axis with a span less than two decades #4867

Closed
Milestone
@zblz

Description

@zblz

For plots with log axis that have limits of the order or less than two decades, only one label is shown:
log_labels

Which does not give a very good idea of the values of the x axis. Adding labels to the minor ticks results in a mess, including non-helpful labels such as10^{4.30}:

ax.xaxis.set_minor_formatter(ticker.LogFormatterMathtext(labelOnlyBase=False))

log_labels_minor_logformattermathtext

And limiting them at[2,5]*base**i results in losing all other minor ticks:

ax.xaxis.set_minor_locator(ticker.LogLocator(subs=[2,5]))

log_labels_minor_at_125_logformattermathtext

The decimals in the exponent can be resolved using LogFormatter, but it is not a nice representation for axis and requires changing the major formatter to match:

ax.xaxis.set_minor_formatter(ticker.LogFormatter(labelOnlyBase=False))ax.xaxis.set_major_formatter(ticker.LogFormatter())

log_labels_minor_at_125_logformatter

Finally, the only way to get them in a consistent manner with the major tick labels, while preserving all minor ticks, is to set them manually, which is far from ideal:

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)

log_labels_minor_at_125_manual_labels

I think that there should be aLogFormatterMathtext with asubs options like the locator, and an option to factors instead of decimal exponents. I will take a look at theLogFormatterMathtext and try to modify it in the following days. If it looks good, I would propose to switch to it automatically for axis spanning less than two decades.

Note that this issue has been reported ina stackoverflow question where a custom formatter is proposed as an answer.
This is somewhat related to the issue#4730 because the lack of labels is particularly noticeable when the axis is around 0.1,1,10, where it would make a lot of sense to have labels at [0.1,0.2,2,5,20,50].

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp