Created
May 4, 2020 05:43
-
-
Save abhishek-shrm/92fbb1541728f50bbea984697a4657ef to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fig=plt.figure(figsize=(10,6)) | |
city=['City A','City B','City C','City D','City E'] | |
x_pos_summer=list(range(1,6)) | |
x_pos_winter=[ i+0.4 for i in x_pos_summer] | |
graph_summer=plt.bar(x_pos_summer, temp_summer,color='tomato',label='Summer',width=0.4) | |
graph_winter=plt.bar(x_pos_winter, temp_winter,color='dodgerblue',label='Winter',width=0.4) | |
plt.title('City Temperature') | |
plt.ylabel('Temperature ($^\circ$C)') | |
plt.ylim(0,45) | |
# removing axes from the figure | |
plt.gca().spines['right'].set_visible(False) | |
plt.gca().spines['top'].set_visible(False) | |
# Image Watermark | |
import matplotlib.image as img | |
av_logo=img.imread(fname='full_logo.png') | |
fig.figimage(av_logo,100,70,alpha=0.3) | |
plt.xticks([i+0.2 for i in x_pos_summer],city,fontname='Chilanka',rotation=45,fontsize=14) | |
for summer_bar,winter_bar,ts,tw in zip(graph_summer,graph_winter,temp_summer,temp_winter): | |
plt.text(summer_bar.get_x() + summer_bar.get_width()/2.0,summer_bar.get_height(),'%.2f$^\circ$C'%ts,ha='center',va='bottom') | |
plt.text(winter_bar.get_x() + winter_bar.get_width()/2.0,winter_bar.get_height(),'%.2f$^\circ$C'%tw,ha='center',va='bottom') | |
plt.legend(loc='upper center',ncol=2,frameon=False) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment