ponnhide / patchworklib

Patchwork for matplotlib: A subplot manager for intuitive layouts in matplotlib, seaborn, and plotnine.
GNU General Public License v3.0
370 stars 24 forks source link

Label size is not reserved from ggplot #15

Closed ChenghaoMou closed 2 years ago

ChenghaoMou commented 2 years ago

Hi, thanks for this cool library!

I noticed that several set_*label calls in load_ggplot doesn't pass on any other style settings such as font size so the axis title always ends up being size 12.

Let me know if you need more information on this.

ponnhide commented 2 years ago

Thank you for your comments. As you mentioned, now, load_ggplot cannot reflect the style settings properly. After the formal release of plotnine 0.9.0 (plotnine seems to be currently being updated), I will fix these problems.

ponnhide commented 2 years ago

I have now updated patchworklib and probably solved the issue. After updating patchworklib and plotnine, please execute the following code.

import patchworklib as pw
from plotnine import *
from plotnine.data import *
g1 = pw.load_ggplot(ggplot(mtcars) 
                    + geom_point(aes("mpg", "disp"))
                    + theme(text=element_text(size=14), axis_title=element_text(size=18)),
                    figsize=(2,3))
g2 = pw.load_ggplot(ggplot(mtcars) 
                    + geom_boxplot(aes("gear", "disp", group="gear"))
                    + theme(text=element_text(size=14), axis_title=element_text(size=18)), 
                    figsize=(2,3))
g3 = pw.load_ggplot(ggplot(mtcars, aes('wt', 'mpg', color='factor(gear)')) 
                    + geom_point() + stat_smooth(method='lm') 
                    + facet_wrap('~gear')
                    + theme(text=element_text(size=14), axis_title=element_text(size=18)), 
                    figsize=(3,3))
g4 = pw.load_ggplot(ggplot(data=diamonds) 
                    + geom_bar(mapping=aes(x="cut", fill="clarity"), position="dodge")
                    + theme(text=element_text(size=14), axis_title=element_text(size=20, color="blue"), 
                            legend_text=element_text(size=14), legend_title=element_text(size=18)), 
                    figsize=(5,2))
g1234 = (g1|g2|g3)/g4
g1234.savefig()

You will get the following output. download

If you face any problems, please let me know.

ChenghaoMou commented 2 years ago

Thank you so much for the fix!