Curve text around coord_polar plot

ggplot2

#1

Using example and answer from this SO post:

library(ggplot2) # ggplot2_2.2.1

# data
df1 <- data.frame(a = c("sensor 1","sensor 2","sensor 3","sensor 4",
                        "sensor very very long text 5",
                        "sensor 6","sensor 7","sensor 8"),
                  b = c(50, 60, 70, 20, 90, 110, 30, 100))

# basic polar bar plot
gg1 <- ggplot(df1, aes(x = a, y = b, fill = a)) + 
  geom_bar(width = 1, stat="identity") +
  coord_polar()

# Accepted answer, it is rotating not curving
# set the angles for each text
myAng <- seq(-20, -340, length.out = 8)
# then update theme with angle
gg1 +
  theme(axis.text.x = element_text(size = 12, angle = myAng)) 

Accepted answer just rotates the text, if the text is short then rotation would be enough, but with long text it could be better to curve, possible?


#2

You might want to look at Circular Visualization in R by Zuguang Gu.
The text section seems to have a few different methods that would fit the bill for you!


#3

This would be a great post (and answer!) to have over at Stack Overflow.

The benefit of posting specific code questions at Stack Overflow is that more people are likely to benefit from the answers when you post there.


Choosing between this site and StackOverflow for posting a question
#4

The question is already on SO, see comments, but accepted answer is just rotating the text, not curving.

zx8754: Accepted solution is rotation… Did you manage to actually curve the text?
nejc-galof: No. The answer is the closest one solution.


#5

Great, I have been through that package, was checking these examples, didn’t see the cookbook, thank you. Will try to adopt and maybe add answer at SO.


#6

Looking at the code for coord_polar(), it seems like it only affects geom positioning. That’s probably for the best: although curved text sounds like a great idea, I’d imagine most other geoms (like lines and points) you wouldn’t want to size or curve around the axis. It could lead to even more perceptual problems than polar plots already have :confused:


#7

Lines do get curved though.