问题描述
我想用coord_polar在ggplot周围制作弯曲的文本.我有data.frame:
I want make curved text around ggplot with coord_polar. I have data.frame:
z <- data.frame( a=c("sensor 1","sensor 2","sensor 3","sensor 4","sensor 5","sensor 6","sensor 7","sensor 8"), b=c(50, 60, 70, 20,90,110,30,100))
这是我创建ggplot的代码:
And here is code where I create my ggplot:
cxc <- ggplot(z, aes(x=a, y=b, fill=factor(b))) +
geom_bar(width = 1,stat="identity",colour = "black")
cxc + coord_polar() +
theme_linedraw() +theme(axis.ticks =element_blank(), axis.text.y =element_blank(), axis.title=element_blank(), axis.text.x=element_text(size = 12,angle = 45))
这是我的结果图像.我想制作文本(x轴):传感器1,传感器2 ...使弯曲,就像我从coord_polar围绕圆画红色一样.必须适合圆圈.
Here is image from my result. I want making texts (x axis): sensor 1, sensor 2... making curved like I draw with red color around circle from coord_polar. Must fit with circle.
推荐答案
我不确定是否要弯曲文本,但是如果您希望它们至少旋转,那么这是一个开始:
I am not sure on curving the text, but if you want them to at least rotate, this is a start:
myAng <-
seq(-20,-340,length.out = 8)
cxc + coord_polar() +
theme_linedraw() +
theme(axis.ticks =element_blank()
, axis.text.y =element_blank()
, axis.title=element_blank()
, axis.text.x=element_text(size = 12
,angle = myAng))
我会犹豫不决地使用这样的角度(对于这样的绘图甚至是极坐标).但是,我认为您有充分的理由这样做,并且此MWE只是没有显示它.
I will add in my hesitation on using such angles (or even polar coordinates for a plot like this). However, I assume that you have a good reason for doing it, and that this MWE just doesn't show it.
这篇关于在coord_polar上制作弯曲的文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!