Reputation: 2253
Let's say I have such data:
a <- tibble(id=c(1,1.1,1.2,1.7,2,2.1,2.6,4,4.6,4.68),
x=c(0.3,0.5,0.2,0.7,0.1,0.5,0.43,0.6,0.3,0.65),
y=c(0.2,0.1,0.22,0.1,0.5,0.2,0.3,0.2,0.14,0.3))
This is just a sample, my real data is much more than this. and x+y+... = 1. I want to draw two lines: one line is for x, one line is for x+y:
ggplot(a) +
geom_line(aes(x=id,y=x),color='red') +
geom_line(aes(x=id,y=x+y),color='blue')
But what I really want something like a radar chart like:
You can see there is a circle with the radius to be 1. x and x+y, (maybe more in my data) are red and blue circles respectively. So, x+y must be larger than x but always in the circle because x+y+...=1. My data has a lot of ids, so it is not the traditional radar with few dimensions.
Upvotes: 2
Views: 208
Reputation: 1252
You can create radar charts with coord_polar()
- e.g.
library(tidyverse)
ggplot(a) +
geom_smooth(aes(x=id,y=x),color='red', se = FALSE) +
geom_smooth(aes(x=id,y=x+y),color='blue', se = FALSE) +
geom_line(aes(x = id, y = 1)) +
coord_polar()
Note, that I used geom_smooth
to get a closer to your intended result.
Upvotes: 1