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

Plots have unwanted transparent background #45

Closed TheArchimedean closed 10 months ago

TheArchimedean commented 1 year ago

Following your example notebook for seaborn plots, I have used the .load_seaborngrid() method on my plots, but the final output has an entirely transparent background which makes things difficult to see. I just want the plot to have a normal white background.

I'll attach my code and an example of the output.

df_nona = pro_df.dropna(subset=['min_salary', 'max_salary', 'rating'])
sns.set_theme()
pw.overwrite_axisgrid() 

#PLOT 1 ##############################################################
graph1 = sns.jointplot(data = df_nona,
                       x = 'rating',
                       y = 'min_salary',
                       kind = 'reg',
                       height = 5
                       )
# label for correlation
r1, p1 = sp.stats.pearsonr(df_nona.rating, df_nona.min_salary)
phantom1, = graph1.ax_joint.plot([], [], linestyle="", alpha=0)
graph1.ax_joint.legend([phantom1],['r={:f}, p={:f}'.format(r1,p1)])

graph1 = pw.load_seaborngrid(graph1, label="graph1")

#PLOT 2 ###############################################################
graph2 = sns.jointplot(data = df_nona,
                       x = 'rating',
                       y = 'max_salary',
                       kind = 'reg',
                       height = 5
                       )
# label for correlation
r2, p2 = sp.stats.pearsonr(df_nona.rating, df_nona.max_salary)
phantom2, = graph2.ax_joint.plot([], [], linestyle="", alpha=0)
graph2.ax_joint.legend([phantom2],['r={:f}, p={:f}'.format(r2,p2)])

graph2 = pw.load_seaborngrid(graph2, label="graph2")

(graph1|graph2)

which produces an output image

ponnhide commented 1 year ago

I'm sorry for the inconvenience. However, I could not reproduce this problem under my environment. Which version of patchworklib are you using?

GBeavis commented 1 year ago

I have the same issue with 0.6.2, which is a fresh install

ponnhide commented 1 year ago

Could you share the entire code that generate this problem?

turtleman99 commented 8 months ago

Met the same problem with plotnine

Tried

pw.case.set_facecolor('white')

or

import matplotlib.pyplot as plt
plt.rcParams['axes.facecolor'] = 'white'

Is the anyway I can manually set the background color as white? Thank you!