Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option to set the opacity of markers in the legend #7208

Open
subwaymatch opened this issue Oct 6, 2024 · 1 comment
Open

Add an option to set the opacity of markers in the legend #7208

subwaymatch opened this issue Oct 6, 2024 · 1 comment
Labels
feature something new P3 backlog

Comments

@subwaymatch
Copy link

Can you kindly consider adding an option to set the opacity of legend markers? Currently, the opacities of the legend's markers are tied to the opacity values of the traces.

Plotly Version
plotly.js v2.35.2

Some scatter plots use a very low opacity (<0.10) to display the concentration of overlapping data points.

👇 This can result in imperceptible marker colors in the legend, as shown below:

👇 Feature request: add an option to set the legend marker opacity

I used a workaround to manually set the opacity of the scatterpts class using CSS.

/* current workaround */
.legendpoints .scatterpts {
  opacity: 1 !important;
}

👇 CodePen for Testing

image

Related posts:

Thank you for maintaining one of the best DataViz libraries! 👍

@gvwilson gvwilson added feature something new P3 backlog labels Oct 7, 2024
@Lexachoc
Copy link
Contributor

I quickly made a support based on your request.

In below, the legend marker's opacity will not using the opacity value from marker.opacity (defined in data) but from legend.opacity (defined in layout)

layout = {
    legend: {
        opacity: 1
    }
}

image

but I wonder if we need to be more specific, e.g., put the opacity option inside the marker (or other name)

layout = {
    legend: {
        marker: {
            opacity: 1
        }
    }
}

Or should it not be within layout, but be inside data for each individual trace (But I guess that would be more complex)?

I need more thoughts/advice from more people (especially the Plotly team) so I can further implement it as there are other types of charts that will use the legend. Currently I'm only focusing on scatter plots and bar charts (and histograms).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature something new P3 backlog
Projects
None yet
Development

No branches or pull requests

3 participants