Advertisement
elena1234

columns visualization with MATPLOTLIB in Python

Mar 9th, 2023 (edited)
1,006
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.58 KB | None | 0 0
  1. titanic.plot(subplots = True, figsize = (15,12), sharex = False, sharey = False)
  2. plt.show()
  3.  
  4. ##################################################
  5. xticks = [x for x in range(0,901, 50)]
  6. xticks
  7.  
  8. yticks = [y for y in range(0, 81, 5)]
  9. yticks
  10.  
  11. plt.style.available
  12.  
  13. plt.style.use("seaborn-v0_8")
  14.  
  15. titanic.age.plot(figsize = (12,8), fontsize= 13, c = "r", linestyle = "-",
  16.                  xlim = (0,900), ylim = (0,80), xticks = xticks, yticks = yticks, rot = 45)
  17. plt.title("Titanic - Ages", fontsize = 15)
  18. plt.legend(loc = 3, fontsize = 15)
  19. plt.xlabel("Passenger No", fontsize = 13)
  20. plt.ylabel("Age", fontsize = 13)
  21. plt.grid()
  22. plt.show()
  23.  
  24. ######################################################
  25. # Histogram
  26. titanic.age.plot(kind = "hist", figsize = (12,8), fontsize = 15, bins = 80, density = True)
  27. plt.show()
  28.  
  29. ######################################################
  30. # Bar chart
  31. summer_2012.Medal.plot(kind = "bar", figsize = (12,8), fontsize = 12)
  32. plt.show() # all countries with their medals
  33.  
  34. summer_2012.Medal.plot(kind = "barh", figsize = (12,8), fontsize = 12)
  35. plt.show()
  36.  
  37. ######################################################
  38. # Pie chart
  39. summer_2012.Medal.plot(kind = "pie", figsize = (12,8), fontsize = 12)
  40. plt.show()
  41.  
  42. ######################################################
  43. # Scatter plot
  44. cars.plot(kind = 'scatter', x = 'horsepower', y = 'mpg', figsize = (12,8), s = 30, c = 'cylinders', marker = 'x', colormap = "viridis")
  45. plt.title('Scatterplot with horsepower and mpg', fontsize = 18)
  46. plt.xlabel("horsepower", fontsize = 15)
  47. plt.ylabel("mpg", fontsize = 15)
  48. plt.show()
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement