r - r ggplot 非线性渐变阿尔法
问题描述
取以下数据
df <- data.frame(ID = c(1, 1, 2, 2, 3, 3),
cond = c(2, 2, 2, 2, 2, 2),
Time = c(1,2,1,2,1,2),
State = c("Empty", "Empty", "Empty", "Full", "Full", "Empty"),
eye = c(2, -3, -2, 1, 0, -2),
combination = c(1, 1,2, 2, 3, 3))
和情节
ggplot(df, aes(x = Time, y = eye)) +
geom_point(aes(shape=State), size = 3.5) +
scale_shape_manual(values=c(13,15)) +
geom_line(aes(group=ID, color = Time, alpha = State), size = 5) +
theme(legend.title=element_blank(),
axis.title.x=element_text(size = 12),
axis.title.y=element_text(size = 12),
plot.title = element_text(hjust = 0.5, size = 15),
axis.text.x= element_text(color = "black"),
axis.text.y= element_text(color = "black"),
axis.line = element_line(colour = "black"),
plot.background = element_rect(fill = "white"),
panel.background = element_rect(fill = "white"))
产生
我的问题是
这为线条提供了不同的 alpha,但我希望线条具有渐变 alpha。具体来说,我需要在“空”和“满”状态之间的线以低 alpha 开始并以高 alpha 结束,从“满”到“空”的线以高 alpha 开始并以低结束α。(从“低”到“低”的线是可以的,就像在示例中一样)。
在 x 轴上,我希望“空”到“满”线从 1.25 开始,然后“淡入”到 2 结束,而不是从 x = 1 开始并在 x = 2 结束,我想要'full' 到 'empty' 行从 1.00 开始,'fade out' 到 1.75 结束。
我一直在为这个问题烦恼一段时间,非常感谢任何帮助。
解决方案
推荐阅读
- java - 是否可以使用 LinearLayouts 在 ImageView 的左侧设置视图?
- javascript - 反应不在渲染上重新排序组件数组
- python - 小数除以大数不起作用
- java - 如何使用微笑库的 CLARANS 方法使用自定义距离矩阵对我的数据进行聚类
- java - image.setImageResource() 何时在函数内设置图像资源?
- reactjs - 为什么 React 应用在布局渲染阶段表现不佳?
- java - 如何在 libgdx 3d 中获得骰子的顶部?
- ios - [UITableViewCell otherFeeLblName]:无法识别的选择器发送到实例 0x7fc45009a000
- python - Rasa X - Google 助理连接器没有收到来自 Rasa 的任何消息
- jspdf - 使用 jspdf-autoTable margin top 两个表之间出现差距