Azathoth42

grafy pro stranu

May 5th, 2020
1,100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.36 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # coding: utf-8
  3.  
  4. import matplotlib.pyplot as plt
  5. import numpy as np
  6. import matplotlib.ticker as mtick
  7.  
  8.  
  9. objects = ('Republika', 'Sovětská Lidová Republika')
  10. y_pos = np.arange(len(objects))
  11. performance = [100, 140]
  12.  
  13. plt.bar(y_pos, performance, align='center')
  14. plt.xticks(y_pos, objects)
  15. plt.gca().yaxis.set_major_formatter(mtick.PercentFormatter())
  16. plt.title('Plnění plánu')
  17. plt.ylim(95, 150)
  18. plt.savefig('plan.png')
  19. plt.show()
  20.  
  21.  
  22. objects = ('Republika', 'Sovětská Lidová Republika')
  23. y_pos = np.arange(len(objects))
  24. performance = [1, 1.5]
  25.  
  26. plt.bar(y_pos, performance, align='center')
  27. plt.xticks(y_pos, objects)
  28. #plt.gca().yaxis.set_major_formatter(mtick.PercentFormatter())
  29. plt.title('Počet obyvatel per capita')
  30. #plt.ylim(95, 150)
  31. plt.savefig('per capita.png')
  32. plt.show()
  33.  
  34.  
  35.  
  36. objects = ('Republika', 'Sovětská Lidová Republika')
  37. y_pos = np.arange(len(objects))
  38. performance = [1, 1.5]
  39.  
  40. #plt.bar(y_pos, performance, align='center')
  41. #plt.xticks(y_pos, objects)
  42. plt.plot([2, 2, 2, 2, 2, 2])
  43. plt.plot([2, 2**2, 2**3, 2**4, 2**5, 2**6])
  44. #plt.gca().yaxis.set_major_formatter(mtick.PercentFormatter())
  45. plt.title('Spokojenost obyvatel, index štěstí, ve dnech od založení')
  46. plt.legend(objects)
  47. #plt.ylim(95, 150)
  48. plt.savefig('happines.png')
  49. plt.show()
  50.  
  51.  
  52. labels = ['Lid']
  53. sizes = [100]
  54. #explode = (0, 0.1, 0, 0)  # only "explode" the 2nd slice (i.e. 'Hogs')
  55.  
  56. fig1, ax1 = plt.subplots()
  57. ax1.pie(sizes, labels=labels, autopct='%1.f%%',
  58.         shadow=True, startangle=90, colors=['red'])
  59. ax1.axis('equal')  # Equal aspect ratio ensures that pie is drawn as a circle.
  60. plt.title('Průzkum volebních preferencí')
  61. plt.savefig('pie.png')
  62. plt.show()
  63.  
  64.  
  65. labels = ['Lid']
  66. sizes = [100]
  67. #explode = (0, 0.1, 0, 0)  # only "explode" the 2nd slice (i.e. 'Hogs')
  68.  
  69. fig1, ax1 = plt.subplots()
  70. ax1.pie(sizes, labels=labels, autopct='%1.f%%',
  71.         shadow=True, startangle=90, colors=['red'])
  72. ax1.axis('equal')  # Equal aspect ratio ensures that pie is drawn as a circle.
  73. plt.title('Rozložení etnické příslušnosti')
  74. plt.savefig('pie_race.png')
  75. plt.show()
  76.  
  77.  
  78.  
  79. objects = ['Těžký prům.', 'Civilní prům.', 'Zemědělství', 'Služby', 'Doprava', 'Volby',
  80.            'Chemický prům.', 'Energetika', 'Plodnost']
  81. y_pos = np.arange(len(objects))
  82. performance = [100] * len(objects)
  83.  
  84. plt.bar(y_pos, performance, align='center', color='r')
  85. plt.xticks(y_pos, objects)
  86. plt.gca().yaxis.set_major_formatter(mtick.PercentFormatter())
  87. plt.xticks(rotation=40)
  88. plt.title('Míra automatizace')
  89. plt.savefig('automa.png')
  90. plt.show()
  91.  
  92.  
  93. objects = ('Republika', 'Sovětská Lidová Republika')
  94. y_pos = np.arange(len(objects))
  95. performance = [1, 1.5]
  96.  
  97. #plt.bar(y_pos, performance, align='center')
  98. #plt.xticks(y_pos, objects)
  99. plt.plot((5+8*np.random.rand(50)).tolist()+np.zeros(50).tolist())
  100. plt.gca().yaxis.set_major_formatter(mtick.PercentFormatter())
  101. plt.gca().axvline(50, color='r')
  102.  
  103. ymin, ymax = plt.ylim()
  104. arrowprops=dict(
  105.         width=3,
  106.         headwidth=10,
  107.         headlength=5,
  108.                   color='r'
  109.     )  
  110. plt.gca().annotate('Revoluce', xy=(50, ymax-1), xytext=(60, -30), textcoords='offset points',
  111.              rotation=0, va='bottom', ha='center', annotation_clip=False, arrowprops=arrowprops)
  112.  
  113. plt.title('Vývoj nezaměstnanosti')
  114. #plt.ylim(95, 150)
  115. plt.savefig('unemployment.png')
  116. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment