Skip to content

Example: quick plotting

Use the -plot operator to quickly plot a dataset, like so:

$ xcdo -plot infile.nc

Warning

This is give an error if the dataset has multiple data variables. Use the -selvar operator to select a single data variable

Dataset with multiple data variables

If the dataset has multiple data variables, use the -selvar operator to select a single data variable, like so:

$ xcdo -plot -selvar,var1 infile.nc

Plotting a single time step

$ xcdo -plot -isel,time=0 -selvar,var1 infile.nc

Note

The -plot operator interally use xarray's plot method, which plots line plots for 1D data, pcolormesh plots for 2D data, and histograms for 3D and above data.

Plotting the fldmean using CDO fldmean operator

$ xcdo -plot -cdo -fldmean -selvar,var1 infile.nc

cdo should be installed

The -cdo operator requires the CDO executable to be installed and available in your PATH.

You can basically chain any number of operators together and give it to the -plot operator and it will plot the result, for example:

$ xcdo -plot -isel,lon=50 -selvar,var1 infile.nc
$ xcdo -plot -cdo -fldmean -ymonmean -selvar,var1 infile.nc

Saving the plot to a file

$ xcdo -plot,figure.png -cdo -fldmean -selvar,var1 infile.nc