I am trying to generate a dumbbell plot in ggplot, while also trying to log transform the x and y axes. System throws an error that I can't understand. Looking for some help.
Here is the sample code:
#create the data
df <- data.frame(x = c(1, 2, 3, 100),
xend = c(2, 4, 6, 110),
y = c(1, 2, 3, 100))
#plot the untransformed dumbbell plot
library('ggalt')
ggplot(df, aes(x = x, xend = xend, y = y)) +
geom_dumbbell()
#Try the plot with coordinate transformation
ggplot(df, aes(x = x, xend = xend, y = y)) +
geom_dumbbell() +
coord_trans(x = 'log2', y = 'log2')
Throws error:
Error in
[.data.frame
(df, , c("alpha", "colour", "size", "linetype")) :
undefined columns selected
If I amend coord_trans
so that coord_trans(x = 'log2', xend = 'log2', y = 'log2)
, I get the error:
Error in coord_trans(x = "log2", xend = "log2", y = "log2") :
unused argument (xend = "log2")
What I want is the equivalent of this, with geom_dumbbell()
rather than geom_point()
:
ggplot(df, aes(x = x, y = y)) +
geom_point() +
coord_trans(x = 'log2', y = 'log2')
Any thoughts on how I can get geom_dumbbell() to work with coord_trans()?