Skip to content

Figure size/aspect for projections is not working anymore with the last version of Matplotlib #210

@mickaellalande

Description

@mickaellalande

Description

I was trying to make a new environment with updated packages, but I faced a colorbar extend warning with the new version but the biggest problem is the size/aspects of the figures that are not good anymore for projections. I think it is coming from the last version of Matplotlib 3.3. Here is the problem with a random example:

Steps to reproduce

import proplot as plot
import xarray as xr

da = xr.tutorial.open_dataset('air_temperature').air - 273.15
clim = da.groupby(da['time.season']).mean('time')

f, axs = plot.subplots(proj='cyl', ncols=2, nrows=2)

for i, ax in enumerate(axs):
    m = ax.contourf(clim.isel(season=i), levels=plot.arange(-30,30,5), extend='both', cmap='CoolWarm')
    
    ax.format(
        labels = True, coast = True, borders = True, lonlines=30, latlines=15, 
        latlim=(clim.lat.min().values, clim.lat.max().values),  
        lonlim=(clim.lon.min().values, clim.lon.max().values),
        title=clim.isel(season=i).season.values
    )
    
f.colorbar(m, label='Near-Surface Air Temperature [°C]')

/data/mlalande/miniconda3/envs/phd_v2/lib/python3.8/site-packages/proplot/figure.py:1158: MatplotlibDeprecationWarning: The 'extend' parameter to Colorbar has no effect because it is overridden by the mappable; it is deprecated since 3.3 and will be removed two minor releases later.
return super().colorbar(*args, cax=cax, **kwargs)

Actual behavior:
extend_phd_v2

Expected behavior
And with my previous environment I was having this:
extend_work

Proplot version

I passed from: (work.txt)

  • proplot 0.5.0
  • matplotlib 3.1.3

to: (phd_v2.txt)

  • proplot 0.6.4
  • matplotlib 3.3.0

I tried to downgrade matplotlib to 3.2, it actually does solve the problem but I still have another issue with the colorbar extend that doesn't work in certain cases (I didn't succeed to reproduce with a simple example...).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions