pydata / xarray

N-D labeled arrays and datasets in Python
https://xarray.dev
Apache License 2.0
3.56k stars 1.07k forks source link

raise AttributeError(f"{type(self).__name__!r} object " AttributeError: 'QuadMesh' object has no property 'cbar' #6218

Closed haritha1022 closed 2 years ago

haritha1022 commented 2 years ago

What happened?

I was trying to plot panel plots but the cbar is not removing

raise AttributeError(f"{type(self).__name__!r} object " AttributeError: 'QuadMesh' object has no property 'cbar' 

What did you expect to happen?

I am unable to remove the color bar I want to remove the color bar

Minimal Complete Verifiable Example

import xarray as xr
import cartopy.crs as ccrs
from cartopy import feature as cf
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
#Opening and reading data
data=xr.open_dataset("uvg.nc")

print(data)
def main():
  x=data.longitude[::5];
  y=data.latitude[::5]
  u=data.u[5,::5,::5];
  v=data.v[5,::5,::5]
  z=data.z[5]
  ax1 = plt.subplot(3,2,1,projection=ccrs.PlateCarree())
  z.plot.pcolormesh(cmap="turbo",vmin=7500,vmax=8500, ax = ax1,cbar=False)
  ax1.set_extent([60, 100, 38, 0])
  ax1.coastlines()

ax1.quiver(x,y,u,v, angles='xy', scale_units='xy', scale=4)
plt.show()

Relevant log output

raise AttributeError(f"{type(self).__name__!r} object " AttributeError: 'QuadMesh' object has no property 'cbar'

Anything else we need to know?

No response

Environment

andersy005 commented 2 years ago

@haritha1022, thank you for the report!

i am unable to remove the color bar. i want to remove the color bar

The issue lies in this line:

z.plot.pcolormesh(cmap="turbo",vmin=7500,vmax=8500, ax = ax1,cbar=False)

The right argument name is add_colorbar instead of cbar:

Screen Shot 2022-01-31 at 9 11 18 AM