【发布时间】:2019-10-18 17:08:33
【问题描述】:
我想在我的情节中添加一个包含所有 hline 统计描述的图例。有什么办法吗?
def test_plot():
Q1=test['age'].quantile(0.25)
Q3=test['age'].quantile(0.75)
IQR=Q3-Q1
fig = (
ggplot(test) +
aes(x=arr,y='age')+
geom_point()+
labs(
title='Test',
x='Index',
y='Age',
)+
geom_hline(aes(yintercept =test.age.mean(),),color = 'gray')+
geom_hline(aes(yintercept =test.age.median()),color = 'green')+
geom_hline(aes(yintercept =IQR),color = 'blue')+
geom_hline(aes(yintercept =test['age'].quantile(0.1)),color= 'red')+
geom_hline(aes(yintercept =test['age'].quantile(0.9)),color= 'yellow')+
geom_hline(aes(yintercept =test['age'].std()),color= 'purple')
)
【问题讨论】:
-
How to add a legend to hline? 可能会有所帮助。
-
在 R 中工作得非常好,但在 python 中在 'override.aes' 处显示错误