3

i have the following plot with the code below, but I keep in the color legend, it does not separate well that I cannot tell the differences very well from the plots. I am wondering how I can change the color bar from, for example, very light green, to dark green. So it is more separated. I tried to add p9.scale_fill_gradient(low="green",high="darkgreen") , but it did not work.

import plotnine as p9
pretty_spk = p9.ggplot(data = data_fully_merged, mapping = p9.aes(x='index', y='value', colour = facet_var))+ p9.geom_point(alpha = alpha_scale)

pretty_spk = pretty_spk + p9.facet_grid("gender~outcome")
title_string = season_str.upper() + " " + facet_var + " " + features_str + " curves facetted by gender and outcome" 
pretty_spk = pretty_spk + p9.geom_smooth(method = 'loess') + p9.ggtitle(title_string) + p9.scale_fill_gradient(low="green",high="darkgreen") 

enter image description here

lll
  • 1,049
  • 2
  • 13
  • 39

1 Answers1

2

For bars it is scale_fill_gradient, but for points you use scale_color_gradient. Not every sure what you mean by more separated color scales. Maybe you can start with below:

from sklearn.datasets import load_iris
import pandas as pd

data = load_iris()
df = pd.DataFrame(data.data, columns=['sepal.length','sepal.width','petal.length','petal.width'])
df.head()

import plotnine as p9
(p9.ggplot(data = df, mapping = p9.aes(x='sepal.length', y='sepal.width', colour = 'petal.length'))+ 
 p9.geom_point()+p9.scale_color_gradient(low="lightgreen",high="darkgreen"))

enter image description here

StupidWolf
  • 45,075
  • 17
  • 40
  • 72