Guest User

Untitled

a guest
Oct 20th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. import numpy as np
  2. import pandas as pd
  3. import altair as alt
  4.  
  5. # This question is about Altair - plotnine is only here for the example data
  6. from plotnine.data import diamonds
  7.  
  8. # This works, and gives me the greenblue color scheme:
  9. alt.Chart(diamonds).mark_rect().encode(
  10. x=alt.X('carat',bin=True),
  11. y=alt.Y('price',bin=True),
  12. color=alt.Color('count()',scale=alt.Scale(scheme='greenblue'))
  13. )
  14.  
  15. # This gives me a log scale, but now the greenblue scheme is gone:
  16. alt.Chart(diamonds).mark_rect().encode(
  17. x=alt.X('carat',bin=True),
  18. y=alt.Y('price',bin=True),
  19. color=alt.Color('count()',scale=alt.Scale(type='log',scheme='greenblue'))
  20. )
  21.  
  22. # Direct specification of range works, but it is not exactly the same
  23. # colors as greenblue. If this is the only way to do it, how do I open
  24. # up the greenblue scheme and grab its colors?
  25. alt.Chart(diamonds).mark_rect().encode(
  26. x=alt.X('carat',bin=True),
  27. y=alt.Y('price',bin=True),
  28. color=alt.Color('count()',scale=alt.Scale(type='log',range=['palegreen','blue']))
  29. )
Add Comment
Please, Sign In to add comment