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

Improve timeline example.#28014

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
jklymak merged 1 commit intomatplotlib:mainfromanntzer:tl
Apr 4, 2024
Merged

Improve timeline example.#28014

jklymak merged 1 commit intomatplotlib:mainfromanntzer:tl
Apr 4, 2024

Conversation

anntzer
Copy link
Contributor

  • Make the timeline vertical, which avoids many overlaps between labels and lines.
  • Sort releases by dates, so that the oldest release starts with a long stemline rather than some random length depending on how many releases there are.
  • Make minor releases fainter, which improves the hierarchical impression.
  • Switch to yearly date labels, which are enough for this timeline.

Old figure:
oldtl
New figure:
tl

Further improvements left as "future work" :-)

PR summary

PR checklist

@github-actionsgithub-actionsbot added the Documentation: examplesfiles in galleries/examples labelApr 3, 2024
@timhoffm
Copy link
Member

timhoffm commentedApr 3, 2024
edited
Loading

I kind of liked the horizontal layout because time is often on the horizontal axis. Can we still get away with that? (If not I also won't block).

The sorting by release date should already decrease overlap of lines and labels a lot. Then, left-align the labels to the bars. You could add a semi-transparent white background to the text to make the overlap less visually distracting.

Additional suggestion: Fill the minor releases with the red line color to make them stand out also on the axis.

@jklymak
Copy link
Member

I would go further and use a smaller font for point releases, and maybe try and have the minor releases always to the far left or far right?

For the one or two releases with visual overlap, I'd actually nudge them manually. Or we could use this as an excuse to show an automated un-overlapping algorithm.

@timhoffm
Copy link
Member

timhoffm commentedApr 3, 2024
edited
Loading

Or we could use this as an excuse to show an automated un-overlapping algorithm.

Let's not stray too far from the main topic. If you want to show an un-overlapping algorithm, that's worth an example of its own (e.g. add annotations to scatter points). 😀

@story645
Copy link
Member

Probably in the future works bin, but this could be a nice example to show off a scroll widget 😅

@anntzer
Copy link
ContributorAuthor

A native scroller (probably not a matplotlib scroll widget...) is something that@efiring has been arguing for for some time, IIRC (I agree that would be useful).

@timhoffm
Copy link
Member

timhoffm commentedApr 3, 2024
edited
Loading

Alternative suggestion:

def level_from_name(name):    minor = int(name[-3])    bugfix = int(name[-1])    h = 1 + 0.8 * (5-bugfix)    return h if minor % 2 == 0 else -hlevels = [level_from_name(name) for name in names]# Create figure and plot a stem plot with the datefig, ax = plt.subplots(figsize=(8.8, 4), layout="constrained")ax.set(title="Matplotlib release dates")ax.vlines(dates, 0, levels,          color=[("tab:red", 1 if name.endswith(".0") else .5) for name in names]))  # The vertical stems.ax.plot(dates, np.zeros_like(dates), "-", color="black")  # baselineminor_dates = [date for date, name in zip(dates, names) if name[-1] == '0']bugfix_dates = [date for date, name in zip(dates, names) if name[-1] != '0']ax.plot(bugfix_dates, np.zeros_like(bugfix_dates), "ko", mfc="white")ax.plot(minor_dates, np.zeros_like(minor_dates), "ko", mfc="tab:red")# annotate linesfor d, l, r in zip(dates, levels, names):    ax.annotate(r, xy=(d, l),                xytext=(-3, np.sign(l)*3), textcoords="offset points",                verticalalignment="bottom" if l > 0 else "top",                bbox=dict(boxstyle='square', pad=0, lw=0, fc=(1, 1, 1, 0.7)))ax.yaxis.set(major_locator=mdates.YearLocator(),             major_formatter=mdates.DateFormatter("%Y"))# remove y-axis and spinesax.yaxis.set_visible(False)ax.spines[["left", "top", "right"]].set_visible(False)ax.margins(y=0.1)plt.show()

image

We still have a bit of overlap, but I like the grouping by minor releases.

@anntzer
Copy link
ContributorAuthor

Yes, that looks way better. I would have put 3.0.0 on the opposite side of 2.2.0, though? so not "minor % 2" but more like "index into the list of major.minor releases (ignoring micro) and get that index %2".

timhoffm reacted with thumbs up emoji

@timhoffm
Copy link
Member

Feel free to take and modify my code.

@anntzer
Copy link
ContributorAuthor

Done. Thanks again :)
tl

rcomer reacted with heart emoji

@jklymak
Copy link
Member

This looks good. As minor nits - I'd drop "v" from each label as very redundant. I'd also make the version labels a different font from the dates either size, italics, or both. But feel free to self merge if you don't agree w those suggestions.

@anntzer
Copy link
ContributorAuthor

Removing the v looks good. I think just making the major releases in bold is enough (the minor releases are never close to the xaxis so they don't get confused with the dates).
tl

- Make the timeline vertical, which avoids many overlaps between labels  and lines.- Sort releases by dates, so that the oldest release starts with a long  stemline rather than some random length depending on how many releases  there are.- Make minor releases fainter, which improves the hierarchical  impression.- Switch to yearly date labels, which are enough for this timeline.
@jklymakjklymak merged commit394b80d intomatplotlib:mainApr 4, 2024
@anntzeranntzer deleted the tl branchApril 4, 2024 16:36
@QuLogicQuLogic added this to thev3.9.0 milestoneApr 4, 2024
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@jklymakjklymakjklymak approved these changes

@timhoffmtimhoffmtimhoffm approved these changes

Assignees
No one assigned
Labels
Documentation: examplesfiles in galleries/examplesDocumentation
Projects
None yet
Milestone
v3.9.0
Development

Successfully merging this pull request may close these issues.

5 participants
@anntzer@timhoffm@jklymak@story645@QuLogic

[8]ページ先頭

©2009-2025 Movatter.jp