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

Matplotlib backend_opts string-based list indexing does not work on ArtistList objects #6158

Open
sztal opened this issue Mar 20, 2024 · 0 comments

Comments

@sztal
Copy link

sztal commented Mar 20, 2024

As in the title. The documentation is somewhat ambiguous on this, but the example in the corresponding part of the documentation (here) suggests that the indexing should work on any sequence-like attribute on matplotlib objects. But this is not the case.

For some reason it is possible to index legend.get_texts()[0:1].fontsize but not axis.texts[0:2].size, even though the ArtistList at axis.texts is a perfectly fine sequence-like object.

I consider this a bug, because this feature is logically implied by the examples given in the docs and there seem to be no reason under the sun to allow for the first and prohibit the second.

I think that there is some too strict an instance check checking for being a subclass of list instead of a generic Sequence.

ALL software version info

holoviews=1.18.3
matplotlib=3.8.0

Description of expected behavior and the observed behavior

Mappings like "axis.texts.size": 24 should just work. Instead they fail with warnings like:

Encountered error: 'ArtistList' object has no attribute 'set_fontsize', or could not find 'set_fontsize' method on 'ArtistList' model. Ensure the custom option spec 'axis.texts[0:2].fontsize' you provided references a valid method on the specified model.

Complete, minimal, self-contained example code that reproduces the issue

# code goes here between backticks
import holoviews as hv
hv.extension("matplotlib")

plot = hv.Text(0, 1, "Text")
plot.opts(
    backend_opts={
        "axis.texts[:].size": 200
    }
)

Stack traceback and/or browser JavaScript console output

Screenshots or screencasts of the bug in action

  • [Yes] I may be interested in making a pull request to address this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant