passing x ticks labels
drveera opened this issue · 2 comments
drveera commented
Hi,
Thanks for this great package. I was wondering if there is an argument to pass the x-tick labels. I'd want to plot odds ratios in the log scale, but label them with their actual OR values. For e.g. I'd like to mark the ticks at [math.log(0.5), math.log(1), math.log(1.5)] and label them as [0.5,1,1.5]
LSYS commented
hi @drveera, yes you get set those using ax.set_xticks()
and ax.set_xticklabels()
, respectively.
Initial plot:
import forestplot as fp
df = fp.load_data("sleep")
ax = fp.forestplot(
df, # the dataframe with results data
estimate="r", # col containing estimated effect size
varlabel="label", # column containing variable label
)
Adjusting xticks and xticklabels:
ax = fp.forestplot(
df, # the dataframe with results data
estimate="r", # col containing estimated effect size
varlabel="label", # column containing variable label
)
ax.set_xticks([-.4,-.3,-.2,.4])
ax.set_xticklabels(["a", "b", "c", "e"])
drveera commented
Awesome! Since I'm not familiar with matplotlib, I didn't know this trick. Thank you very much.