ggplot2:根据值添加渐变彩色方块
关于我想要做什么,我有一个棘手的问题。 我有一个图,上面有两条线(两个条件的平均值)。我想在同一个图上添加一个反映 t 值的正方形(并根据这些值以渐变方式着色)。我怎样才能添加这个正方形?
好吧,因为我不知道我是否清楚,这是我试图实现的目标的一个数字。
感谢您的帮助!
I have a tricky question regarding to what i'm trying to do.
I have a plot with two lines (the mean of two conditions) on it. I want to add on the same plot a square reflecting the t-values (and colored according to these values in a gradient way). How could i add this square?
Well since i don't know if i'm clear, here is a figure of what i try to achieve.
Thank you for any help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试使用 ggplot2 方式:
已更新
您可以使用
scale_fill_XXX< /代码>。这是一个jet-color版本:
在ggplot2的下一个版本中,您可以使用colorbar作为图例。
Try this for ggplot2 way:
UPDATED
You can use
scale_fill_XXX
. Here is a jet-color version:and in the next version of ggplot2, you can use colorbar as the legend.
对于基础图形,您可以使用 rasterImage 函数将带有渐变的矩形添加到图形中。
For base graphics you can use the
rasterImage
function to add a rectangle with the gradient in it to a graph.