Skip to content

Remember metadata when passing mappables to colorbar() #81

Closed
@mickaellalande

Description

@mickaellalande

I have another suggestion of enhancement regarding what Cartopy does. By default, ProPlot uses the long_name attribute of a DataArray as a title of the figure, but not the units attribute. Here is the default behavior of Cartopy when doing a plot (data: ens_avg_snow_cyclic.zip):

import xarray as xr
import proplot as plot

ens_avg_snow_cyclic = xr.open_dataarray('ens_avg_snow_cyclic.nc')
ens_avg_snow_cyclic.plot()

cartopy_units

It automatically puts the long_name and units attribute of the DataArray beside the color bar. In addition, it writes as a title the coordinates left (I didn't do any projection, the goal is only to show the labels here).

It would be nice to at least have the units after the title in ProPlot too, in addition to the actual default behavior shown here:

f, axs = plot.subplots(proj='cyl', width=8)

m = axs[0].contourf(ens_avg_snow_cyclic, cmap='BuRd')

f.colorbar(m)

axs.format(
    geogridlinewidth=0.5, geogridcolor='gray8', geogridalpha=0.5, labels=True, 
    coast=True, ocean=True, oceancolor='gray3', latlim=(20,90),
    suptitle=str(ens_avg_snow_cyclic.season.values) + ' climatology'
)

proplot_default

Like for example (here are 3 different possibilies I am thinking):
proplot_default_1
proplot_default_2
proplot_default_3

Or having the same behavior as Cartopy like the 2nd example and putting as a title the left coordinates as coord_name = values. Here it is the season, but usually, if we select a date, it shows time = .... After it doesn't have to be like Cartopy, in my opinion adding at least the units would be already nice :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions