Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pivot_to_plot = (data
- .pivot_table(index='locality_name' , values='price_per_area', aggfunc=('count', 'mean'))
- .sort_values('count', ascending=False)
- .head(10)
- )
- plt.figure(figsize=(20,10))
- plt.title('Средняя стоиомсть метра и количество объектов')
- ax1 = pivot_to_plot['count'].plot(kind = 'bar',color='blue', grid=True, label='Count')
- ax2 = pivot_to_plot['mean'].plot(color='red', grid=True, secondary_y=True, label='Mean')
- #строим легенду
- h1, l1 = ax1.get_legend_handles_labels()
- h2, l2 = ax2.get_legend_handles_labels()
- plt.legend(h1+h2, l1+l2, loc=1)
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement