【发布时间】:2018-07-17 16:11:42
【问题描述】:
我正在尝试在将希腊字母与撇号和文本相结合的 ggplot2 图中注释文本。到目前为止,我无法实现探针。
现在,我可以写如下标签,结合annotate和geom_text,代码如下:
ggplot(Lab_all_direct_shear)+
geom_rect(aes(xmin = 0, xmax = 20, ymin = 0, ymax = 120), color = NA, fill="grey", alpha = 0.05)+
geom_segment(linetype = 8,color="#666666",aes(x = 0, y = 0, xend = 55, yend = 88.649))+
geom_point(size=3,shape=21,fill ="#F8766D",aes(x=constitutive_normal_stress_15_kPa,y=constant_volume_shear_strenght_15_kPa))+
geom_point(size=3,shape=21,fill ="#00BA38",aes(x=constitutive_normal_stress_19_kPa,y=constant_volume_shear_strenght_19_kPa))+
geom_point(size=3,shape=21,fill ="#619CFF",aes(x=constitutive_normal_stress_25_kPa,y=constant_volume_shear_strenght_25_kPa))+
scale_x_continuous(limits = c(0,60),breaks=c(0,10,20,30,40,50,60),expand = c(0, 0)) +
scale_y_continuous(limits = c(0,120), breaks=c(0,10,20,30,40,50,60,70,80,90,100,110,120),expand = c(0, 0)) +
labs(x=expression(~sigma[n]~+~s~S[r]~(kPa)),y = "",title="") +
annotate("text", x = 54, y = 70, label = "= 58.2°",size=4)+
geom_text(x=50,y=70,label="phi",parse=TRUE)+
theme_bw() +
theme(plot.title = element_text(size=10, face="bold", hjust=0.5),
axis.title = element_text(size=10),
axis.title.x = element_text(angle=0, hjust=0.5),
axis.title.y = element_blank(),
axis.text = element_text(size=10,color="black"),
axis.text.x = element_text(size=10),
axis.text.y = element_blank(),
panel.grid.major = element_line(color= NA),
panel.grid.minor = element_line(color= NA),
plot.margin=unit(c(0.1,0.2,0.1,0.4), "cm"), #The four numbers are c(top,right,bottom,left)
legend.text = element_text(size=10),
legend.title = element_text(size=10),
legend.position = "none")
R ggplot2 包中的结果:
greek letter annotate without apostrophe
我尝试了不同的组合(将其声明为表达式、粘贴等,但我无法解决)。
我想在 excel 中获得这样的图,带有以下注释(带有上标撇号的 phi 与文本相结合):
excel plot with desired annotation
任何帮助将不胜感激!
提前致谢, 劳尔
【问题讨论】:
标签: r ggplot2 symbols apostrophe annotate