0

I have a plot of a map containing areas which are color coded. I need to remove the automatic color bar from the plot and replace with a legend. However, I cannot find a way to remove the color bar. Xarray was used to create the data array.

map_crs = ccrs.OSGB()
fig = plt.figure(figsize=(10, 15))
cmap = mpl.colors.ListedColormap(colours)
norm = mpl.colors.BoundaryNorm(boundaries=bins, ncolors=len(cmap.colors)-1 )
stamen_terrain = cigmt.Stamen('terrain')
ax = plt.axes(projection=stamen_terrain.crs)

data_array.plot(transform=map_crs, vmin=0, vmax=np.max(data_array), cmap=cmap)

plt.gca().coastlines()
plt.tight_layout()
plt.savefig(plotname, bbox_inches="tight", pad_inches=0.1)
plt.clf()

I have tried adding commands such as, colorbar=False, cbar=False, Colorbar=False. However, just continually receive the corresponding error;

AttributeError: 'QuadMesh' object has no property 'Colorbar'

Any ideas on how to get rid of the colorbar?

shafee
  • 15,566
  • 3
  • 19
  • 47
Helen
  • 1
  • 1

1 Answers1

0

Done!

Just needed to put add_colorbar=False into the plotting command.

Now to add the legend!

Helen
  • 1
  • 1