1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| import os # saving files
import matplotlib.pyplot as plt # plot and visualizing data
## create directory for results
result_dir = 'DATA/'
directory = result_dir
if not os.path.exists(directory):
os.makedirs(directory)
ax = plt.subplot()
rects = ax.bar(distance_z[0], population[0], width =0.5, color = 'b', align = 'center', alpha =1)
plt.xlabel('distance')
ax.set_title('data1')
plt.savefig(result_dir + 'my-data1'+ '.pdf', transparent=True, bbox_inches='tight')
ax = plt.subplot()
rects = ax.bar(distance_z[1], population[1], width =0.5, color = 'r', align = 'center', alpha =1)
plt.xlabel('distance')
ax.set_title('data2')
plt.savefig(result_dir + 'my-data2'+ '.pdf', transparent=True, bbox_inches='tight')
ax = plt.subplot()
rects = ax.bar(distance_z[3], population[3], width =0.5, color = 'g', align = 'center', alpha =1)
plt.xlabel('distance')
ax.set_title('data3')
plt.savefig(result_dir + 'my-data3'+ '.pdf', transparent=True, bbox_inches='tight') |
Partager