Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fig, ax1 = plt.subplots(figsize=(12,7))
- ax2=ax1.twinx()
- sns.lineplot(x='yq',y='value.R', data=dataset, hue='group', ax=ax1, legend = None)
- ax1.set_xticklabels(ax1.get_xticks(), rotation=45)
- ax1.set_xlabel("")
- ax1.set_ylabel("")
- ax1.set_ylim((0, max(dataset['value.R']) + 0.05))
- sns.barplot(x='yq', y='value.YQGR', data=dataset, hue='group', ax=ax2)
- ax2.set_yticklabels(['{:.1f}%'.format(a*100) for a in ax2.get_yticks()])
- ax2.set_ylabel("")
- ax2.set_ylim((min(dataset['value.YQGR']) - 0.01, max(dataset['value.YQGR']) + 0.2))
- ax2.get_legend().remove()
- ax2.legend(bbox_to_anchor=(0., 1.02, 1., .102), loc=3, borderaxespad=0., ncol = 3)
- for carrier in ax2.containers:
- for bar in carrier:
- ax2.text(
- bar.get_xy()[0] + bar.get_width()/1,
- bar.get_height() + 0.001,
- '{:.1f}%'.format(round(100*bar.get_height(),2)),
- color='black',
- horizontalalignment='center',
- fontsize = 9, weight = 'heavy'
- )
- ax1.yaxis.set_visible(False)
- ax2.yaxis.set_visible(False)
- ax2.xaxis.set_visible(False)
- ax1.spines["right"].set_visible(False)
- ax1.spines["left"].set_visible(False)
- ax1.spines["top"].set_visible(False)
- ax1.spines["bottom"].set_visible(False)
- ax2.spines["right"].set_visible(False)
- ax2.spines["left"].set_visible(False)
- ax2.spines["top"].set_visible(False)
- ax2.spines["bottom"].set_visible(False)
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement