matplotlib的basemap怎样绘制分省地图

如题所述

第1个回答  2017-08-22
两种常用图类型:Lineandscatterplots(使用plot()命令),histogram(使用hist()命令)2.1折线图&散点图Lineandscatterplots2.1.1折线图Lineplots(关联一组x和y值的直线)importnumpyasnpimportpylabasplx=[1,2,3,4,5]#Makeanarrayofxvaluesy=[1,4,9,16,25]#Makeanarrayofyvaluesforeachxvaluepl.plot(x,y)#usepylabtoplotxandypl.show()#showtheplotonthescreen图例Figurelegendspl.legend((plot1,plot2),(’label1,label2’),'best’,numpoints=1)其中第三个参数表示图例放置的位置:'best’‘upperright’,‘upperleft’,‘center’,‘lowerleft’,‘lowerright’.如果在当前figure里plot的时候已经指定了label,如plt.plot(x,z,label=cos(x2)),直接调用plt.legend()就可以了哦。importnumpyasnpimportpylabasplx1=[1,2,3,4,5]#Makex,yarraysforeachgraphy1=[1,4,9,16,25]x2=[1,2,4,6,8]y2=[2,4,8,12,16]plot1=pl.plot(x1,y1,’r’)#usepylabtoplotxandy:Giveyourplotsnamesplot2=pl.plot(x2,y2,’go’)pl.title(’Plotofyvs.x’)#giveplotatitlepl.xlabel(’xaxis’)#makeaxislabelspl.ylabel(’yaxis’)pl.xlim(0.0,9.0)#setaxislimitspl.ylim(0.0,30.)pl.legend([plot1,plot2],(’redline’,’greencircles’),’best’,numpoints=1)#makelegendpl.show()#showtheplotonthescreen
相似回答