Skip to content
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

Add sublabel_index and sublabel_skip option for matplotlib backend #6375

Merged
merged 5 commits into from
Sep 25, 2024

Conversation

LecrisUT
Copy link
Contributor

@LecrisUT LecrisUT commented Sep 17, 2024

This allows to alter the index count of the sublabels, e.g. I have the following plot:
Screenshot_20240917_145922

But the top element (a)) is not an actual subplot, just a colorbar for all the other. But exposing this option allows to basically ignore the first subplot. When numbering. In another situation I have an opposite problem, where I created a group of plots, but then I attach manually another subplot within LaTeX, then I want the numbering to skip a few labels.

@hoxbro
Copy link
Member

hoxbro commented Sep 17, 2024

Do you have a MRE I can play around with? I'm not entirely sure if this is the best way to expose this customization.

@LecrisUT
Copy link
Contributor Author

import holoviews

holoviews.extension("matplotlib")

# For simplicity, let's just copy the plots
curve = holoviews.Curve([0, 1, 2])
layout = holoviews.Layout()
layout += curve
layout += curve
layout += curve
layout += curve
layout.cols(2)
layout.opts(
    sublabel_format=r"{alpha})",
    sublabel_index_offset=-1,
)

@hoxbro hoxbro added the type: enhancement Minor feature or improvement to an existing feature label Sep 18, 2024
@LecrisUT
Copy link
Contributor Author

I'm afraid sublabel_skip only addresses half the problem. The other half is wanting to offset the labeling, e.g. start from c) instead of a), in the example, making sublabel_index_offset=2

@hoxbro
Copy link
Member

hoxbro commented Sep 18, 2024

I pushed some changes, changing from sublabel_index_offset to sublabel_skip so you can skip multiple elements.

import holoviews as hv

hv.extension("matplotlib")

c = lambda: hv.Curve([0, 1, 2])
layout = (c() + c() + c() + c()).cols(2)
layout.opts(sublabel_skip=[1, 3])

image

I will look into the other part of your requests later.

Copy link

codecov bot commented Sep 18, 2024

Codecov Report

Attention: Patch coverage is 86.11111% with 5 lines in your changes missing coverage. Please review.

Project coverage is 88.50%. Comparing base (e11c52c) to head (684b823).
Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
holoviews/plotting/mpl/plot.py 68.75% 5 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main    #6375    +/-   ##
========================================
  Coverage   88.49%   88.50%            
========================================
  Files         323      323            
  Lines       68184    68311   +127     
========================================
+ Hits        60341    60458   +117     
- Misses       7843     7853    +10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@LecrisUT
Copy link
Contributor Author

This interface works for my needs 👍

@hoxbro hoxbro changed the title Add sublabel_index_offset option for matplotlib backend Add sublabel_index and sublabel_skip option for matplotlib backend Sep 19, 2024
@hoxbro hoxbro merged commit 90f56c8 into holoviz:main Sep 25, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement Minor feature or improvement to an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants