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

Using theme_matplotlib() fails with 'object' object has no attribute 'startswith' #784

Closed
magv opened this issue May 11, 2024 · 1 comment
Labels

Comments

@magv
Copy link

magv commented May 11, 2024

Hi, all. On my machine theme_matplotlib() consistently fails. Here's an example:

from pandas import DataFrame
from plotnine import *

theme_set(theme_matplotlib())

PLOT = (
 ggplot(DataFrame([{"X":0,"Y":0},{"X":1,"Y":2}])) +
 aes('X', 'Y') +
 geom_point()
);
PLOT.save('test.png')

This is what I get when I run it:

Traceback (most recent call last):
  File "test.py", line 11, in <module>
    PLOT.save('test.png')
  File ".../site-packages/plotnine/ggplot.py", line 664, in save
    sv = self.save_helper(
  File ".../site-packages/plotnine/ggplot.py", line 613, in save_helper
    figure = self.draw(show=False)
  File ".../site-packages/plotnine/ggplot.py", line 272, in draw
    with plot_context(self, show=show):
  File ".../site-packages/plotnine/_utils/context.py", line 48, in __enter__
    self.rc_context.__enter__()
  File ".../contextlib.py", line 135, in __enter__
    return next(self.gen)
  File ".../site-packages/matplotlib/__init__.py", line 1188, in rc_context
    rcParams.update(rc)
  File ".../_collections_abc.py", line 994, in update
    self[key] = other[key]
  File ".../site-packages/matplotlib/__init__.py", line 733, in __setitem__
    cval = self.validate[key](val)
  File ".../site-packages/matplotlib/rcsetup.py", line 252, in validate_backend
    s if s is _auto_backend_sentinel or s.startswith("module://")
AttributeError: 'object' object has no attribute 'startswith'

This is with Python 3.10.5, matplotlib 3.8.4, and 0.13.6.

Is there anything I can do to make this work?

@has2k1
Copy link
Owner

has2k1 commented May 14, 2024

I cannot reproduce this. I think there is something wrong with you installation.

@has2k1 has2k1 added the Invalid label May 14, 2024
@has2k1 has2k1 closed this as completed May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants