rloggdp = np.log(riogdp['GDP (millions of US$)']) # logarithm of gdp for countries played at rio
sloggdp = np.log(sochigdp['GDP (millions of US$)']) # logarithm of gdp for countries played at sochi
# --- the plots
fig, axes = plt.subplots(4, 1, figsize=(50, 100))
#x = np.arange(0,len(count['countries']),1)
# plot 0
axes[0].scatter(rloggdp, riogdp['Total'], 5, color='blue')
# plot 1
axes[1].scatter(sloggdp, sochigdp['Total'], 5, color='blue')
# plot 2
axes[2].scatter(riosochi['Totaltoprio'], riosochi['Totaltopsochi'], 5, color='blue')
# plot 3
xlocs = np.arange(len(sortrs.index))
axes[3].bar(xlocs-0.4, sortrs['Totaltoprio'], 0.4,
color='blue', label='Medals won at Rio')
axes[3].bar(xlocs, sortrs['Totaltopsochi'], 0.4,
color='green', label='Medals won at Sochi')
# --- pretty-up and save
# plot 0
xrange = np.arange(0, rloggdp.max(), 1)
axes[0].set_xticks(xrange)
axes[0].set_xticklabels(xrange)
axes[0].tick_params(axis='both', which='major', length=5, width=20, labelsize=25,)
axes[0].grid(True, which='both')
#axes[0].yaxis.grid(True)
#axes.legend(loc='best', fontsize=25)
axes[0].set_ylabel('Total Medal Count', labelpad=20, fontsize=25)
axes[0].set_xlabel('GDP of a country', labelpad=20, fontsize=25)
axes[0].set_yticks(np.arange(0, toprio['Total'].max(), 5))
#plt.ylim([0,2*countT['total_medals'][0]])
m, b = np.polyfit(rloggdp,riogdp['Total'], 1)
axes[0].plot(x, m*x + b, '-', color ='darkorchid', linewidth=2)
axes[0].set_title('GDP vs Total medal counts won at Rio', fontsize=25)
# plot 1
xrange = np.arange(0, sloggdp.max(), 1)
axes[1].set_xticks(xrange)
axes[1].set_xticklabels(xrange)
axes[1].tick_params(axis='both', which='major', labelsize=25,)
axes[1].yaxis.grid(True)
#axes.legend(loc='best', fontsize=25)
axes[1].set_ylabel('Total Medal Count', labelpad=20, fontsize=25)
axes[1].set_xlabel('GDP of a country', labelpad=20, fontsize=25)
axes[1].set_yticks(np.arange(0, topsochi['Total'].max(), 5))
#plt.ylim([0,2*countT['total_medals'][0]])
m, b = np.polyfit(sloggdp,sochigdp['Total'], 1)
axes[1].plot(x, m*x + b, '-', color ='darkorchid', linewidth=2)
axes[1].set_title('GDP vs Total medal counts won at Sochi', fontsize=25)
# plot 2
xrange = np.arange(0, riosochi['Totaltoprio'].max(), riosochi['Totaltoprio'].max()/40)
axes[2].set_xticks(xrange)
axes[2].set_xticklabels(xrange, rotation=90)
axes[2].tick_params(axis='both', which='major', labelsize=20,)
axes[2].yaxis.grid(True)
#axes.legend(loc='best', fontsize=25)
axes[2].set_ylabel('Total Medal Count won at Sochi', labelpad=20, fontsize=25)
axes[2].set_xlabel('Total Medal Count won at Rio', labelpad=20, fontsize=25)
axes[2].set_yticks(np.arange(0, topsochi['Total'].max(), 5))
#plt.ylim([0,2*countT['total_medals'][0]])
m, b = np.polyfit(riosochi['Totaltoprio'], riosochi['Totaltopsochi'], 1)
axes[2].plot(x, m*x + b, '-', color ='darkorchid', linewidth=2)
axes[2].set_title('Total medal counts won at Rio vs Total medal counts won at Sochi', fontsize=25)
# plot 3
axes[3].set_xticks(xlocs)
axes[3].set_xticklabels(sortr.index, rotation=90)
axes[3].tick_params(axis='both', which='major', labelsize=25)
axes[3].yaxis.grid(True)
axes[3].legend(loc='best', fontsize=25)
axes[3].set_ylabel('Total Medal counts', labelpad=20, fontsize=25)
axes[3].set_xlabel('Countries', labelpad=20, fontsize=20)
axes[3].set_yticks(np.arange(0, max(riosochi['Totaltoprio'].max(), riosochi['Totaltopsochi'].max()), 5))
axes[3].set_title('Total medal counts won at Rio and total medal counts won at Sochi for all countries', fontsize=25)
fig.suptitle("Olympic Medals and GDP Charts", y=1.03, fontsize=35)
#fig.tight_layout(pad=2)
fig.savefig('ctm.png', dpi=125)
matplotlib mehrere Diagramme. Apperance falsch oder schlecht
Dies ist eine grafische Darstellung der mehrere Diagramme vertikal nacheinander angezeigt. Kann nicht alle deutlich anzeigen. Warum werden die Beschriftungen und/oder Teilstriche der Achse für die ersten beiden Diagramme gequetscht und der Rest des Diagramms ist leer? Was kann ich noch tun, um die Charts besser aussehen zu lassen? Danke