2

我有下面的代码图,但我保留在颜色图例中,它不能很好地分开,我无法从图中很好地分辨出差异。我想知道如何将颜色条从例如非常浅的绿色更改为深绿色。所以更加分离。我尝试添加 p9.scale_fill_gradient(low="green",high="darkgreen") ,但它没有用。

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") 

在此处输入图像描述

4

1 回答 1

1

对于酒吧来说,它是scale_fill_gradient,但对于你使用的点scale_color_gradient。并非每个人都知道更多分离的色阶是什么意思。也许你可以从下面开始:

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"))

在此处输入图像描述

于 2020-02-09T00:03:33.750 回答