0

I use 'xarray' to read nc file and plot a figure. I achieved the figure, but I don't know how to modify the title of the figure. Please see the code below.

import xarray as xr
ds = xr.open_dataset('/users/james/Downloads/_data2/test2.nc')
ds['u10'].sel(latitude=-1.3,longitude=50.7,method='nearest').plot()

I hope someone could help me, thank you!

廖智宇
  • 21
  • 5
  • 1
    xarray plots with matplotlib under the hood, so you can use normal matplotlib tools. see e.g. https://stackoverflow.com/questions/7066121/how-to-set-a-single-main-title-above-all-the-subplots-with-pyplot – Michael Delgado May 03 '22 at 02:31

1 Answers1

1

It's the same as how you use matplotlib as Mike said in the comment.

For your case, just use plt.title('your title').

Yu-Fen
  • 43
  • 9