0

I am attempting to make a figure with 12 plots showing the monthly average of a parameter from the 1800's to the 2100's for each month. I have the plots pretty much finished with the average monthly data for each month and 12 plots, I just want to add coastlines. I have attempted to add "coastlines = True" to the end of my contour() plotting line, where I got a warning message stating, "The following kwargs were not used by contour: 'coastline'". I have also tried using ax.coastlines() after my plotting command and I get an error message saying, "'FacetGrid' object has no attribute 'coastlines'". The final thing I tried to do is below:

fg = cape_climo.plot.contourf(x = 'lon', y = 'lat', col =    'month', col_wrap =3, ,
                        subplot_kws={
        "projection": ccrs.LambertConformal()}, cbar_kwargs={"orientation": "vertical", "shrink": 0.8, "aspect": 40},
    robust=True) 

fg.map(lambda: plt.gca().coastlines())

I get no error or warning message with this...but I also get no coastlines.

Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
franke11
  • 35
  • 5
  • Always provide a [mre] **with code, data, errors, current output, and expected output, as text**. Only plot images are okay. Please see [How to ask a good question](https://stackoverflow.com/help/how-to-ask). – Trenton McKinney Sep 03 '20 at 01:15
  • That is the code I am attempting to use...I am getting a contoured map, and I need to put coastlines on it. I have provided errors I received in my explanation, as well as my current and expected output. Thanks. – franke11 Sep 03 '20 at 01:27
  • This isn't a [mre] because it's not reproducible without data – Trenton McKinney Sep 03 '20 at 01:30

1 Answers1

2

fg contains a axes property containing all created axes, so you can do the following:

[ax.coastlines() for ax in fg.axes.flatten()]

Note in newer versions of xarray this is axs instead of axes:

[ax.coastlines() for ax in fg.axs.flatten()]
mathause
  • 1,607
  • 1
  • 16
  • 24