Quickstart

There are three equivalent ways to plot a netCDF file with NCPlot: from plain Python, through the xarray accessor, or from the command line. Pick whichever fits how you already work.

Plot from Python

Import view and point it at a file path or URL. With no vars argument, every variable in the file is plotted:

python
from ncplot import view

# plot everything in the file
view("example.nc")

# or just the variable(s) you care about
view("example.nc", vars="sst")
view("example.nc", vars=["sst", "sss"])

x can also be a directory of netCDF files, or a remote OPeNDAP/THREDDS URL — NCPlot reads them the same way it reads a single local file.

Plot an xarray dataset or data array

If you already have data open in xarray, import the accessor once to add a .ncplot namespace to every Dataset and DataArray:

python
import ncplot.xarray
import xarray as xr

ds = xr.open_dataset("example.nc")
ds.ncplot.view()

# works on a single DataArray too
ds["sst"].ncplot.view(coast=True)

This calls the same view function underneath, so every keyword argument documented in the API reference works here too.

Plot from the command line

NCPlot also installs a command line tool. Point it at one or more files and it opens an interactive view in your browser — no Python session needed:

console
$ ncplot example.nc
$ ncplot https://psl.noaa.gov/thredds/dodsC/Datasets/COBE2/sst.mon.ltm.1981-2010.nc

Pass more than one file (or URL) and NCPlot views them together.

Next steps