Advertisement
elena1234

custom histogram in Python

Oct 24th, 2022 (edited)
680
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.85 KB | Source Code | 0 0
  1. df_diesel["bins"] = pd.cut(df_diesel['Price BGN'], [0,5000,10000,15000,20000,4000000])
  2. ax = df_diesel["bins"].value_counts(normalize=True).plot.bar()
  3. ax.bar_label(ax.containers[0], label_type='edge')
  4. plt.xlabel('Price BGN')
  5. plt.ylabel('Percentages')
  6. plt.title("Diesel engines: Price Distribution")
  7. plt.show()
  8.  
  9. #####################################################################################
  10. plt.figure(figsize=(14, 8), dpi=100)
  11. x = transform_df['Salary']
  12. y = transform_df['Count']
  13. plt.bar(x, y ,align='center') # A bar chart
  14. plt.xlabel('Средна заплата')
  15. plt.ylabel('Преброяване')
  16. for i in range(len(y)):
  17.     plt.hlines(y[i],0,x[i]) # Here you are drawing the horizontal lines
  18. plt.title('Разпределение на обявите за свободни работни места към 7 октомври 2022')
  19. plt.show()
  20.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement