0

I have a data set which provides latitude, longitude, and temperature for a time series of oceanographic readings.

Right now I am plotting the trajectory through lat/lon space thus:

fig = plt.figure()
ax = fig.add_subplots(111)
ax.plot(lon, lat, 'o')

I want to have each dot display in a color representative of the temperature at that location (and display a colorbar). How would I go about doing this? If it's pertinent, this is actually a map from the basemaps toolkit. Thanks.

This was marked as duplicate; none of the solutions provided in the questions which it purportedly duplicates works.

Here is the code in its entirety:

map = Basemap(llcrnrlon = -160, llcrnrlat = -90, urcrnrlon = 40, 
urcrnrlat = 10, resolution = 'l')


map.drawcoastlines()
map.drawcountries()
map.fillcontinents(color='gray')
map.drawmapboundary(


cs = map.scatter(lon,lat, c = temp[0])

plt.savefig('test.pdf')

plt.show()

It raises this error:

ValueError: Invalid RGBA argument: <xarray.DataArray 'TEMP' ()>
array(6.459000110626221)
2
  • @ImportanceOfBeingErnest The solutions in the posts you claim this duplicates don't work. Thanks. Commented Nov 29, 2017 at 18:34
  • 1
    Sure, they all work fine. If you have a problem with them, you need to provide a minimal reproducible example of the issue. Commented Nov 29, 2017 at 21:48

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.