Skip to content

DOC: fix stylesheet again #21796

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

Closed
wants to merge 3 commits into from
Closed

Conversation

jklymak
Copy link
Member

@jklymak jklymak commented Nov 29, 2021

PR Summary

This makes the stylesheet one figure (with subfigures) to allow us to better control the legibility (I hope)

PR Checklist

Styles

Tests and Styling

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (install flake8-docstrings and run flake8 --docstring-convention=all).

Documentation

  • New features are documented, with examples if plot related.
  • New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).

@jklymak
Copy link
Member Author

jklymak commented Nov 29, 2021

Based on #21782 @dstansby (who I added as a co-author).

Closes #21734

@jklymak jklymak added this to the v3.5-doc milestone Nov 29, 2021
@jklymak jklymak force-pushed the doc-fix-stylesheet branch 2 times, most recently from da79690 to ee4f516 Compare November 29, 2021 14:49
Copy link
Member

@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really like the subfigures solution because of the workarounds needed for figure-related styling.

Overall, I'd rather have sphinx gallery behaving and not us working around that. But maybe this PR is the quickest stop-gap on our side.

fig, axs = plt.subplots(ncols=6, nrows=1, num=style_label,
figsize=fig_size, squeeze=True)
axs[0].set_ylabel(style_label)
axs[0].figure.set_facecolor(plt.rcParams['figure.facecolor'])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a workaround because all subfigures are created with one style. This will not be needed for standard use cases where one has one figure only. I think this workaround needs a comment.

Are there more figure-based parameters that would need to be adapted?

Comment on lines 116 to 122
col = np.array([19, 6, 84])/256
back = mcolors.rgb_to_hsv(
mcolors.to_rgb(plt.rcParams['figure.facecolor']))[2]
if back < 0.5:
col = [0.8, 0.8, 1]
axs[0].figure.suptitle(style_label, x=0.03, fontsize=12,
ha='left', color=col)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seemingly obscure workaround needs a comment as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes fair. I don't really consider this example a code example so wasn't too worried about being didactic. Also this suptitle is not meant to illustrate the styles - it was meant to be distinct.

Co-authored by: David Stansby <dstansby@gmail.com>
@jklymak
Copy link
Member Author

jklymak commented Nov 30, 2021

BTW, I have no idea if sphinx-gallery can be made to do a one-column layout, and wouldn't object to that solution at all.

@QuLogic
Copy link
Member

QuLogic commented Dec 2, 2021

We already override some sphinx-gallery CSS in mpl.css, so I think it should not be difficult to disable the multicolumn layout from there.

@QuLogic
Copy link
Member

QuLogic commented Dec 2, 2021

Adding to mpl.css:

.sphx-glr-multi-img {                           
        max-width: 100%;           
}

appears enough, but we'd have to check how much this affects other pages. It would also affect:

$ rg -l -g'*.html' sphx-glr-multi-img doc/build/html/
doc/build/html/gallery/color/named_colors.html
doc/build/html/gallery/color/colormap_reference.html
doc/build/html/gallery/ticks/tick-formatters.html
doc/build/html/gallery/lines_bars_and_markers/fill_betweenx_demo.html
doc/build/html/gallery/event_handling/pick_event_demo.html
doc/build/html/gallery/event_handling/zoom_window.html
doc/build/html/gallery/userdemo/demo_gridspec03.html
doc/build/html/gallery/text_labels_and_annotations/accented_text.html
doc/build/html/gallery/text_labels_and_annotations/annotation_demo.html
doc/build/html/gallery/axes_grid1/demo_axes_rgb.html
doc/build/html/gallery/style_sheets/style_sheets_reference.html
doc/build/html/gallery/images_contours_and_fields/barb_demo.html
doc/build/html/gallery/images_contours_and_fields/contourf_demo.html
doc/build/html/gallery/specialty_plots/advanced_hillshading.html
doc/build/html/gallery/images_contours_and_fields/image_demo.html
doc/build/html/gallery/images_contours_and_fields/shading_example.html
doc/build/html/gallery/statistics/boxplot_demo.html
doc/build/html/tutorials/colors/colors.html
doc/build/html/tutorials/colors/colormaps.html

@QuLogic
Copy link
Member

QuLogic commented Dec 2, 2021

I've gone through all figures listed above, and I think they all look better at full resolution, except that some of them really should be split up (with text that's already there sometimes), thus avoiding this styling entirely.

The only two figures that make sense to go together are at https://matplotlib.org/stable/tutorials/colors/colors.html#cn-color-selection, but they happen to work anyway because they're small enough to fit on one line.

@jklymak
Copy link
Member Author

jklymak commented Dec 2, 2021

Sure if we prefer a css solution I'm fine with that!

@QuLogic
Copy link
Member

QuLogic commented Dec 2, 2021

See #21837; that avoids having to do the subfigure stuff here, but I think there are still some fixes here we might still want (e.g., skipping internal styles)?

@timhoffm
Copy link
Member

timhoffm commented Dec 5, 2021

Superseeded by #21837.

@timhoffm timhoffm closed this Dec 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants