dputhier · GitHub

Hi,
In R, the mapping between colors and points is achieved through a named vector in the scale_color_manual function. I tried several solutions in plotnine, using list, list of tuples, dict, structured array (...). I'm unable to achieve proper mapping. Could you help me with this simple example:

  import pandas as pd
  from plotnine import  *
  m = pd.DataFrame({'x':range(15), 'y':range(15), 'c': ['A']*5+['B']*5+['C']*5})
  # What should I write to get points 'A' in red, 'B' in violet... ?
  # Maybe the most natural for a beginner is a dict (imho)
  ggplot(m, aes('x','y', color='c')) + geom_point(size=3) + scale_color_manual({'A':'red', 'B':'violet', 'C': 'blue'})

Thank you

Read the original on github.com ↗