Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import pandas as pd
- import altair as alt
- # This question is about Altair - plotnine is only here for the example data
- from plotnine.data import diamonds
- # This works, and gives me the greenblue color scheme:
- alt.Chart(diamonds).mark_rect().encode(
- x=alt.X('carat',bin=True),
- y=alt.Y('price',bin=True),
- color=alt.Color('count()',scale=alt.Scale(scheme='greenblue'))
- )
- # This gives me a log scale, but now the greenblue scheme is gone:
- alt.Chart(diamonds).mark_rect().encode(
- x=alt.X('carat',bin=True),
- y=alt.Y('price',bin=True),
- color=alt.Color('count()',scale=alt.Scale(type='log',scheme='greenblue'))
- )
- # Direct specification of range works, but it is not exactly the same
- # colors as greenblue. If this is the only way to do it, how do I open
- # up the greenblue scheme and grab its colors?
- alt.Chart(diamonds).mark_rect().encode(
- x=alt.X('carat',bin=True),
- y=alt.Y('price',bin=True),
- color=alt.Color('count()',scale=alt.Scale(type='log',range=['palegreen','blue']))
- )
Add Comment
Please, Sign In to add comment