问题描述:

I have created a global contour for d18O with a specified range and colorbar.

lon = np.arange(-180.0,180.0,1)

lat = np.arange(-90.0,90.0,1)

m1 = Basemap(projection='mill',llcrnrlat=-90,urcrnrlat=90,

llcrnrlon=-180,urcrnrlon=180,resolution='c')

x,y = m1(*np.meshgrid(lon, lat))

colors=[-5.6,-4.4,-3.6,-3.2,-2.8,-2.4,-2.0,-1.7,-1.4,-1.1,-.8,-.5,

-.2,.2,.4,.6,.8,1.0,1.3,1.6,2.0,2.4,2.8]

m1.contourf(x, y, d18o_fal,colors) #d18o_fal is a 360x180 matrix of d18O values.

m1.drawcoastlines()

m1.fillcontinents()

m1.drawmapboundary()

plt.title(Fall+' Calculated Surface $\delta^{18}$O Seawater')

cbar = plt.colorbar(orientation='horizontal', extend='both')

cbar.ax.set_xlabel('O18/O16 permilli')

plt.show()

I am trying to plot a scatterplot of the arctic with the color intensity equal to the intensity of d18O (Figure a). The points are from long, lat, and d18o.

Much like this:

http://imgur.com/uExeiYB

(Figure 1A)

Sorry I can't post pictures yet!

网友答案:

I'm not entirely clear on where you get the "intensity of d18O" but basically you need to call scatter() with the c parameter set to a list of intensity (same size as the number of points), and map the color using a cmap.

see the documentation for scatter

and tons of examples on SO: matplotlib colorbar for scatter

相关阅读:
Top