Skip to content

scale_colour_manual html hex colour transparency doesn't appear in legend #665

Closed
@harrig12

Description

@harrig12

I'd like to set point transparency using html hex code

I don't want a separate alpha legend, just the colour one to be transparent. Although this works for the points themselves, the transparency doesn't seem to propagate to the legend when using set_colour_manual

In R, I might use override.aes but I haven't found the equivalent in plotnine

Any suggestions?

import numpy as np
import pandas as pd
from plotnine import * 

data = np.random.rand(20, 4)
df = pd.DataFrame(data)
df.columns = ['x', 'facet 1', 'facet 2', 'facet 3']
df['label'] = ['label 1']*10 + ['label 2']*5 + ['label 3']*5
df = pd.melt(df, id_vars=['x', 'label'])

g=(ggplot(df)
+ aes(x='x', y='value', color='label')
+ geom_point(size=10)
+ theme_seaborn('white')
+ scale_colour_manual({'label 1': 'orange', 'label 2': 'red', 'label 3': '#0000FF4D'})
)

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions