Skip to content

Bug: Faceting fails with levels (easy to fix) #1461

@zlatko-minev

Description

@zlatko-minev

Faceting example fails with levels

flatui = ["#9b59b6", "#3498db", "#95a5a6", "#e74c3c", "#34495e", "#2ecc71"]
g_simple = t.plot(x='lon', y='lat', col='time', col_wrap=3,
                  levels=[0, 12, 18, 30], colors=flatui)

The generated error is

ValueError: Can't specify both cmap and colors.

I tracked this down inside newplotfunc to the line

 return _easy_facetgrid(**allargs)

which calls FacetGrid.map_dataarray

This function does not check if levels is assigned. And hence automatically adds a cmap on the second panel of the plot

        cmap_args = inspect.getargspec(_determine_cmap_params).args
        cmap_kwargs.update((a, kwargs[a]) for a in cmap_args if a in kwargs)

        cmap_params = _determine_cmap_params(**cmap_kwargs)

the check fails after that.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions