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

Doesn't work with Plotnine Seaborn Theme #37

Closed
ZwFink opened this issue Apr 3, 2023 · 1 comment
Closed

Doesn't work with Plotnine Seaborn Theme #37

ZwFink opened this issue Apr 3, 2023 · 1 comment

Comments

@ZwFink
Copy link

ZwFink commented Apr 3, 2023

Hello,
The following code fails when theme_seaborn is used in plotnine:

from plotnine import *
import pandas as pd
import patchworklib as pw
df = pd.DataFrame(columns=['benchmark', 'technique', 'value', 'platform'])
df.loc[0] = ['BO', 'Item1', 3.0, 'A']
df.loc[1] = ['BO', 'Item2', 2.0, 'A']
df.loc[2] = ['BO', 'Item3', 4.0, 'A']
df.loc[3] = ['BO', 'Item1', 5.0, 'B']
df.loc[4] = ['BO', 'Item2', 2.0, 'B']
df.loc[5] = ['BO', 'Item3', 6.0, 'B']
p1=(
    ggplot(df, aes(fill="technique", y="value", x="value")) + theme_seaborn() + 
    geom_col(stat='identity', position='dodge')
)
p1_b = pw.load_ggplot(ggplot=p1, figsize=(5,4))

with the following error:

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
Cell In[56], line 16
     11 df.loc[5] = ['BO', 'Item3', 6.0, 'B']
     12 p1=(
     13     ggplot(df, aes(fill="technique", y="value", x="value")) + theme_seaborn() + 
     14     geom_col(stat='identity', position='dodge')
     15 )
---> 16 p1_b = pw.load_ggplot(ggplot=p1, figsize=(5,4))

File [~/.local/lib/python3.9/site-packages/patchworklib/patchworklib.py:437](https://file+.vscode-resource.vscode-cdn.net/home/zane/projects/LLNL/hpac_performance/2023-02-01_amdgpu/analysis/~/.local/lib/python3.9/site-packages/patchworklib/patchworklib.py:437), in load_ggplot(ggplot, figsize)
    434 ax.change_aspectratio((figsize[0], figsize[1])) 
    436 if StrictVersion(plotnine_version) >= StrictVersion("0.9"):
--> 437     draw_labels(ax, ggplot, gcp) 
    438     draw_legend(ax, ggplot, gcp, figsize)
    439     draw_title(ax,  ggplot, gcp, figsize)

File [~/.local/lib/python3.9/site-packages/patchworklib/patchworklib.py:273](https://file+.vscode-resource.vscode-cdn.net/home/zane/projects/LLNL/hpac_performance/2023-02-01_amdgpu/analysis/~/.local/lib/python3.9/site-packages/patchworklib/patchworklib.py:273), in load_ggplot..draw_labels(bricks, gori, gcp)
    270 gori.figure._themeable['axis_title_x'] = xlabel
    271 gori.figure._themeable['axis_title_y'] = ylabel
--> 273 gori.theme.themeables['axis_title_x'].apply_figure(gori.figure)
    274 for ax in gori.axs:
    275     gori.theme.themeables['axis_title_x'].apply(ax)

KeyError: 'axis_title_x'

But it does work when theme_seaborn() is commented out. It looks like the plotnine seaborn theme doesn't define theme.themeables['axis_title_x'].

@ponnhide
Copy link
Owner

Patchworlib v0.6.1 supports theme_seaborn plotnine v0.10.1, but will not support the future version of plotnine.

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

2 participants