I am trying to make a bar plot that has extra data on it. Associated with each data point is a value from a factor that indicates why the height is what it is. So far I'm reasonably happy with my results:
library(ggplot2)
tab <- read.table("http://www.cs.colorado.edu/~coxaj/table2.csv",
header=T, sep=",", strip.white=T)
tab <- with(tab, tab[order(Analysis, -as.numeric(Analysis)), ])
bar_width <- 0.5
space_width <- 0.8
p <- ggplot(tab, aes(x=Filter,y=Depth,fill=Analysis)) +
geom_bar(position=position_dodge(width=space_width), width=bar_width) +
geom_point(position=position_dodge(width=space_width), aes(shape=Termination)) +
scale_shape_manual(values=c(1,4,5,6)) +
geom_hline(aes(yintercept=16, linetype=2)) +
scale_x_discrete(name='') +
scale_y_continuous(name='Search Depth') +
scale_fill_manual(values=c("#E66101", "#FDB863", "#B2ABD2", "#5E3C99")) +
theme_bw()
ggsave(filename='table2.pdf', height=3, width=8)
This produces a plot that looks like this:
The problem is that it puts these pointless circles in the legend for Analysis. I would like to remove that circle, but keep the legend. Does ggplot2 let me do this?
try this:
p <- ggplot(tab, aes(x=Filter,y=Depth)) +
geom_bar(aes(fill = Analysis),
position=position_dodge(width=space_width), width=bar_width) +
geom_point(position=position_dodge(width=space_width),
mapping = aes(group = Analysis, shape=Termination)) +
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With