Advertisement
Guest User

Untitled

a guest
Jun 15th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. fig, ax1 = plt.subplots(figsize=(12,7))
  2. ax2=ax1.twinx()
  3. sns.lineplot(x='yq',y='value.R', data=dataset, hue='group', ax=ax1, legend = None)
  4. ax1.set_xticklabels(ax1.get_xticks(), rotation=45)
  5. ax1.set_xlabel("")
  6. ax1.set_ylabel("")
  7. ax1.set_ylim((0, max(dataset['value.R']) + 0.05))
  8. sns.barplot(x='yq', y='value.YQGR', data=dataset, hue='group', ax=ax2)
  9. ax2.set_yticklabels(['{:.1f}%'.format(a*100) for a in ax2.get_yticks()])
  10. ax2.set_ylabel("")
  11. ax2.set_ylim((min(dataset['value.YQGR']) - 0.01, max(dataset['value.YQGR']) + 0.2))
  12. ax2.get_legend().remove()
  13. ax2.legend(bbox_to_anchor=(0., 1.02, 1., .102), loc=3, borderaxespad=0., ncol = 3)
  14. for carrier in ax2.containers:
  15. for bar in carrier:
  16. ax2.text(
  17. bar.get_xy()[0] + bar.get_width()/1,
  18. bar.get_height() + 0.001,
  19. '{:.1f}%'.format(round(100*bar.get_height(),2)),
  20. color='black',
  21. horizontalalignment='center',
  22. fontsize = 9, weight = 'heavy'
  23. )
  24. ax1.yaxis.set_visible(False)
  25. ax2.yaxis.set_visible(False)
  26. ax2.xaxis.set_visible(False)
  27. ax1.spines["right"].set_visible(False)
  28. ax1.spines["left"].set_visible(False)
  29. ax1.spines["top"].set_visible(False)
  30. ax1.spines["bottom"].set_visible(False)
  31. ax2.spines["right"].set_visible(False)
  32. ax2.spines["left"].set_visible(False)
  33. ax2.spines["top"].set_visible(False)
  34. ax2.spines["bottom"].set_visible(False)
  35. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement