gghighlight 2个特定点ggplot2

时间:2018-12-11 22:03:09

标签: r ggplot2 regression linear-regression

尝试突出显示下一组数据中的2个特定点:

Entry,DWSpk,FE
1,1.335703125,36.075
2,1.0821875,45.79413708
3,1.28984375,36.925
5,0.910625,49.125
6,0.8728125,55.9
7,0.84125,56.925
8,0.93875,46.775
9,1.159453125,41.575
10,1.11375,40.45
Rialto,0.89140625,51.875
Savannah,1.33609375,35.275

尝试下一个代码:

p1 <- ggplot(HiBAP1517, aes(FE,DWSpk)) + 
  geom_point(shape=16) + 
  gghighlight(FE==51.875 & FE==35.275) + 
  geom_smooth(method=lm, se = F) + 
  theme(axis.title.x = element_text(color="black", size=14, face="bold"),
        axis.title.y = element_text(color="black", size=14, face="bold"))

pfinal <- p1 + labs(y = expression("DM spk"^{-1}*"g"),
                    x = expression("FE"*(grainsg^{-1})))
pfinal

但是似乎不起作用...有什么主意吗?

1 个答案:

答案 0 :(得分:1)

这应该有效。我已经评论了您对代码的主要修改。

var str ="101";
var num = Number(str);
var int = parseInt(str);

enter image description here