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

ticker.StrMethodFormatter("{x:0.0f}") appears to obscure rather than clean year values #1

Open
@dcronkite

Description

@dcronkite

On, e.g., ch3-ex2 and ch4-ex1, a string formatter is used to 'format' years on the x-axis which would otherwise appear as decimals (2015.0 -> 2015, 2017.5 -> 2018). This, however, appears to distort the actual x-axis labels, showing '2018' when at the spot which ought to be labeled '2017.5'.

You can see this from the following 2 code snippets using chapter3-example2, cell 8 (note the difference in the 2017.5 and 2018 labels which point to the same location):

fig, ax = plt.subplots()ax.plot(avg_by_year.year, avg_by_year.comb08)ax.xaxis.set_major_formatter(ticker.StrMethodFormatter('{x:0.0f}'))

with_decimal

fig, ax = plt.subplots()ax.plot(avg_by_year.year, avg_by_year.comb08)ax.xaxis.set_major_formatter(ticker.StrMethodFormatter('{x:0.1f}'))

without_decimal

I think the correct code to avoid the '20XX.5' in years might be something likeax.set_xticks(np.arange(2000, 2020, 2))?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp