I am trying to do a waterfall plot like the following example:
base2 <- data.frame(rot=c("PRini","shk1","PRfim"), value=c(10,5,15),order=c(1,2,3), fim=c(10,15,0),
inicio=c(0,10,15), imp=c("net","pos","net"))
ggplot(base2, aes(fill = imp)) +
geom_rect(aes(x = rot,
xmin=order - 0.3,
xmax=order + 0.3,
ymin=fim,
ymax=inicio),
position="dodge")
When I execute that code, I receive the following message:
Warning: Ignoring unknown aesthetics: x
If I remove the x
argument, the following message is displayed:
Error: position_dodge requires the following missing aesthetics: x
When I remove the position
argument, the plot is showed up, but without the x
labels. I want some suggestion to remove the first warning
keeping the x
labels.
put all of the aesthetics in your ggplot(aes()), then you won't get a warning. The geom_rect() will get the aes from ggplot() then.
ggplot(base2, aes(fill = imp, x = rot, xmin=order - 0.3,
+ xmax=order + 0.3,
+ ymin=fim,ymax=inicio)) +
+ geom_rect( position="dodge")
another solution as dirty workaround:
it seems your plot is fine, but it just gives you the warning. You also could also use suppressWarnings()
for ignoring the warning.