-
Notifications
You must be signed in to change notification settings - Fork 794
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
Specify the color #921
Comments
Here you go: import altair as alt
import pandas as pd
mv_dict = {'type': ['values', 'values'], 'quantity': [5, 10], 'category': ['mv', 'no_mv']}
df = pd.DataFrame(mv_dict)
alt.Chart(df).mark_bar().encode(
y='type',
x='sum(quantity)',
color=alt.Color('category',
scale=alt.Scale(
domain=['mv', 'no_mv'],
range=['red', 'green']))) |
Awesome, thanks! |
You can also use Edit: scheme should be a scale argument |
@jakevdp , I tried what you posted: however doing: |
sorry, yes, scheme is a Scale argument. glad you figured it out 😄 |
@jakevdp Do you have any tips on using vega schemes with log scales? I tried |
@Artemis-R I have the same issue as you but for the case where I set |
The specified colors break if you concatenate charts. :\ |
Is there a way to specifically have the 0 value returns a white color and the rest in the normal scheme? |
@fredgi123 this answer on another issue was helpful. I also tried blues in an attempt to get 0 to display as white. I just used this discrete method to describe the scale I'd like to see. If you don't mind what the middle values are, you only have to specify 0, the cutoff for white coloring, and max. I added in the clamp=True param to make sure they weren't interacting with one another. #2258 (comment) |
With this piece of code, the graph is generated automatically using blue for 'mv' and orange for 'no_mv'
Since in some contexts, the color has an implicit connotation...could it be possible to specify what color I want to use for 'mv' (e.g. red) and what for 'no_mv' (e.g. green)?
The text was updated successfully, but these errors were encountered: