Skip to content

Example of how to override the bar chart color with plotly.express #2241

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

Closed
chriddyp opened this issue Mar 2, 2020 · 4 comments
Closed

Example of how to override the bar chart color with plotly.express #2241

chriddyp opened this issue Mar 2, 2020 · 4 comments

Comments

@chriddyp
Copy link
Member

chriddyp commented Mar 2, 2020

https://plot.ly/python/bar-charts/

@emmanuelle
Copy link
Contributor

Which syntax do you prefer @chriddyp @nicolaskruchten ?

import plotly.express as px
data_canada = px.data.gapminder().query("country == 'Canada'")
fig = px.bar(data_canada, x='year', y='pop', color_discrete_sequence=["red"])
fig.show()

or

import plotly.express as px
data_canada = px.data.gapminder().query("country == 'Canada'")
fig = px.bar(data_canada, x='year', y='pop')
fig.update_traces(marker_color='red')
fig.show()

Both have their pros and cons: the one-liner in px is nice, but it's also good to show people they can update traces and layout after calling px. I slightly prefer the 1st (all-px), but interested in your opinion.

@emmanuelle
Copy link
Contributor

Also add an example in the box-plots tutorial.

And related to #2119.

@AtharvaKatre
Copy link
Contributor

@emmanuelle is it possible to add a Continuous color scale like 'Viridis' to a bar plot?

@gvwilson
Copy link
Contributor

Hi - we are trying to tidy up the stale issues and PRs in Plotly's public repositories so that we can focus on things that are still important to our community. Since this one has been sitting for several years, I'm going to close it; if it is still a concern, please add a comment letting us know what recent version of our software you've checked it with so that I can reopen it and add it to our backlog. Thanks for your help - @gvwilson

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

No branches or pull requests

4 participants