python - Basemap drawparallels tick label color -
i have possibly simple question. simplified version of code below:
# rid of white stripe on map ionst, lons=addcyclic(ionst, lons) #setting figure attributes fig=plt.figure(figsize=(15,15),frameon=false, facecolor='gray') #map settings m=basemap(llcrnrlon=-180, llcrnrlat=-87.5, urcrnrlon=180, urcrnrlat=87.5,rsphere=6467997, resolution='l', projection='cyl',area_thresh=10000, lat_0=0, lon_0=0) #creating 2d array of latitude , longitude lon, lat=np.meshgrid(lons, lats) xi, yi=m(lon, lat) #plotting data onto basemap cs=m.imshow(varcor, interpolation=none, alpha=.8, cmap='seismic', vmin=-.02, vmax=.02) vert=plt.axvline(x=-75, color='black', linewidth=5) #drawing grid lines m.drawparallels(np.arange(-90.,90.,30.),labels=[1,0,0,0],fontsize=20) m.drawmeridians(np.arange(-180.,181.,45.), labels=[0,0,0,1],fontsize=20) #drawing coast lines m.drawcoastlines()
when call drawparallels , drawmeridians argument, labels set according array specify. figured out how change size of tick labels can't life of me figure out how change color. tried feeding in directly argument color=, tried tick_params, tried xticks, yticks, etc...
any ideas? thanks!
after extensive searching found solution on web. not straight forward works:
from mpl_toolkits.basemap import basemap import matplotlib.pyplot plt import numpy np def setcolor(x, color): m in x: t in x[m][1]: t.set_color(color) m = basemap(lon_0=0) m.drawcoastlines() par = m.drawparallels(np.arange(-90,90,30),labels=[1,0,0,1]) setcolor(par,'r') merid = m.drawmeridians(np.arange(0,360,60),labels=[1,0,0,1]) setcolor(merid,'r') plt.show()
Comments
Post a Comment