Skip to content

Error in scale_color #944

Open
Open
@Yijia-Jiang

Description

@Yijia-Jiang

Hello, when using plotnine for ggplot, I get this following error that happens when running this function:

class scale_color_cmap(scale_continuous):
"""
Create color scales using Matplotlib colormaps

Parameters
----------
cmap_name :
    A standard Matplotlib colormap name. The default is
    `viridis`. For the list of names checkout the output
    of `matplotlib.cm.cmap_d.keys()` or see the
    `documentation <http://matplotlib.org/users/colormaps.html>`_.
{superclass_parameters}
na_value : str, default="#7F7F7F"
    Color of missing values.

See Also
--------
[](`matplotlib.cm`)
[](`matplotlib.colors`)
"""

_aesthetics = ["color"]
guide = "colorbar"
na_value = "#7F7F7F"

def __init__(self, cmap_name: str = "viridis", **kwargs):
    from mizani.palettes import cmap_pal

    # TODO: fix types in mizani
    self.palette = cmap_pal(cmap_name)  # pyright: ignore
    super().__init__(**kwargs)

The error is:

File /opt/anaconda3/envs/spatial_data/lib/python3.9/site-packages/plotnine/ggplot.py:175, in ggplot._display(self)
172 save_format = "png"
174 buf = BytesIO()
--> 175 self.save(buf, format=save_format, verbose=False)
176 display_func = get_display_function(format)
177 display_func(buf.getvalue())
...
476 # TODO: fix types in mizani
--> 477 self.palette = cmap_pal(cmap_name) # pyright: ignore
478 super().init(**kwargs)

TypeError: cmap_pal() takes no arguments
Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings...

Can you please help? Thank you a lot

Metadata

Metadata

Assignees

No one assigned

    Labels

    ReprexNeeds a Minimal Reproducible Example

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions