JadeChee
JadeChee

Reputation: 89

Contour on color map: not continuous (Python)

I made some color maps in python. On top of them I wanted to add some continental contours, using the land-sea mask provided in the model I run. It consists of just 1 or 0, 1 for land and 0 for no-land. There is some strange characters written into the contour plot. Does anyone here knows how I could get the contour to connect to itself so it's smooth instead of being broken with those small strange characters in between the ends of each line?

Here is what the figure looks like: enter image description here

And here is a piece of the code (note this map was part of a plot containing other maps, so this is the map of index 9).

lsmfile = netcdf.netcdf_file("/Volumes/LaCie/Plasim/Earth2/high/1367/SOL1367earth050.nc","r")
lat = lsmfile.variables["lat"].data
lon = lsmfile.variables["lon"].data
mask = lsmfile.variables["lsm"].data
mask = mask[0]
cmap = plt.get_cmap('bwr')

fig, ax = plt.subplots(nrows=5,ncols=2,figsize=(16,14))
im9 = ax.flat[9].pcolormesh(lon, lat, surfalbearth, cmap=cmap,norm=norm)
fig.colorbar(im9, ax=ax.flat[9])
ax.flat[9].set_xlim(xmin=0, xmax=355)
ax.flat[9].set_ylim(ymin=-86, ymax=86)
CS = plt.contour(lon,lat,mask, 1,colors='k')
plt.clabel(CS, fontsize=3, inline=1)

fig.tight_layout() 
plt.savefig('Maps')
plt.show()

Upvotes: 1

Views: 1166

Answers (1)

ImportanceOfBeingErnest
ImportanceOfBeingErnest

Reputation: 339300

It seems you have asked for having those contour labels (clabel) in your plot by using the line

plt.clabel(CS, fontsize=3, inline=1)

So if you remove that line, the contour labels should disappear.

Upvotes: 1

Related Questions