|
| 1 | +import matplotlib.gridspec as gridspec |
| 2 | +import matplotlib.pyplot as plt |
| 3 | +import numpy as np |
| 4 | +import pandas as pd |
| 5 | + |
| 6 | +import forestplot as fp |
| 7 | + |
| 8 | +# fill in |
| 9 | +df = pd.read_csv('test.csv') |
| 10 | + |
| 11 | +headers = ['Header 1','Header 2','Header 3','Header 4','Header 5'] |
| 12 | +header_short = ['h1', 'h2', 'h3', 'h4', 'h5'] |
| 13 | + |
| 14 | +fig, axarr = plt.subplots(2, 3, figsize=(20,20), sharey=True) |
| 15 | +fig.tight_layout(h_pad=2) |
| 16 | + |
| 17 | +k = 0 |
| 18 | +for i in range(2): |
| 19 | + for j in range(3): |
| 20 | + col = header_short[k] |
| 21 | + ax = fp.forestplot(df, ax=axarr[i,j], estimate=col+'1', ll=col+'2', hl=col+'3', |
| 22 | + varlabel='label', |
| 23 | + ci_report=False, |
| 24 | + **{"marker": "D", # set maker symbol as diamond |
| 25 | + "markersize": 35, # adjust marker size |
| 26 | + "xlinestyle": (0, (10, 5)), # long dash for x-reference line |
| 27 | + "xlinecolor": ".1", # gray color for x-reference line |
| 28 | + "xtick_size": 12, # adjust x-ticker fontsize |
| 29 | + "fontsize": 14, |
| 30 | + } ) |
| 31 | + if j > 0: |
| 32 | + ax.axes.get_yaxis().set_visible(False) |
| 33 | + ax.set_xlim(-.09, .09) |
| 34 | + ax.set_title(headers[k])#, loc='left') |
| 35 | + k += 1 |
| 36 | + if k >= 5: |
| 37 | + break |
| 38 | + |
| 39 | +axarr[-1,-1].axis('off') |
| 40 | + |
| 41 | +plt.savefig('test.png', bbox_inches='tight', dpi=300) |
0 commit comments