I would like to use a brewer qualitative palette using plotnine, but I get the error:
ValueError: Invalid color map name 'Set1' for type 'Sequential'.
Valid names are: ['Blues', 'BuGn', 'BuPu', 'GnBu', 'Greens', 'Greys', 'OrRd', 'Oranges', 'PuBu', 'PuBuGn', 'PuRd', 'Purples', 'RdPu', 'Reds', 'YlGn', 'YlGnBu', 'YlOrBr', 'YlOrRd']
Reproducible example
from plotnine import *
import pandas as pd
df = pd.DataFrame({'a': [0,1,2,3,4], 'b': [0,-2,10,6,8], 'c': ['a', 'b', 'a', 'a', 'b']})
(ggplot(df, aes(x = 'a', y = 'b', color = 'factor(c)')) +
geom_line() +
scale_color_brewer(palette = 'Set1'))
In ggplot2 in R, however, you can do the same and get the correct plot
library(ggplot2)
df = data.frame(a = c(0,1,2,3,4), b = c(0,-2,10,6,8), c = c('a', 'b', 'a', 'a', 'b'))
ggplot(df, aes(x = a, y = b, color = factor(c))) +
geom_line() +
scale_color_brewer(palette = "Set1")
You have to include the "type" argument
scale_fill_brewer(type="qual", palette="Set1")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With