forestplot icon indicating copy to clipboard operation
forestplot copied to clipboard

Plot output looks strange when using custom plot style

Open kirtanp opened this issue 1 year ago • 0 comments

I have a dataframe with the minimum required columns and the following test code.

fp.forestplot(df_result,  # the dataframe with results data
              estimate="coef",  # col containing estimated effect size 
              ll="ll", hl="hl",  # columns containing conf. int. lower and higher limits
              varlabel="variable",  # column containing variable label
              ylabel="Confidence interval",  # y-label title
              xlabel="Pearson correlation",  # x-label title
              )

I then get an output as follows

Image

I have the following lines in my code. If I remove plt.style.use(['science', 'nature']), then the table looks better, but the titles are not bold, and it looks fine if I also remove the font specification.

import matplotlib as mpl
import scienceplots
mpl.rcParams.update(mpl.rcParamsDefault)
rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
plt.style.use(['science', 'nature'])

I was just wondering if there is a way around this and whether this is a known problem that editing the default mpl settings can break things in the forest plot. Thank you!

kirtanp avatar Jan 27 '25 17:01 kirtanp