LSYS / forestplot

A Python package to make publication-ready but customizable coefficient plots.
http://forestplot.rtfd.io
MIT License
110 stars 10 forks source link

Requesting an option to change the location of x-reference line #77

Closed nadthoob closed 1 year ago

nadthoob commented 1 year ago

When plotting hazard or odds ratios in forest plots it would be helpful to be able to change the location of x-reference line--to move it from x=0 to x=1.

EythorE commented 1 year ago

I have been passing the kwarg "xline" to fp.forestplot which is then passed to draw_ref_xline(), similar to the customization examples in https://forestplot.readthedocs.io.

import forestplot as fp
import pandas as pd
import matplotlib.pyplot as plt

df = pd.DataFrame({'name': ['name_a', 'name_b'], 'estimate': [1.1, 1.0]})
df['Lower CI'] = df['estimate'] - 0.05
df['Upper CI'] = df['estimate'] + 0.05

fp.forestplot(df,
              estimate='estimate',
              varlabel='name',
              ll="Lower CI", hl="Upper CI", 
              figsize=(5,2)
              **{
                  "xline": 1,
                  "xlinestyle": (1, (10, 5)) # long dash for x-reference line
              }
            )
plt.show()

forest_move_x

LSYS commented 1 year ago

@nadthoob please see the above response by @EythorE

thanks @EythorE !

github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 1 year ago

This issue was closed because it has been inactive.