Reputation: 31
I am working on ggplot2, here is my sample data,
type <- c("A", "B", "C", "D", "E","F")
point <- c(3,5,8,6,100,9)
data <- data.frame(type, point)
ggplot(data, aes(x=type, y=point, fill="type")) +
geom_bar(stat="identity") +
geom_text(data=data, aes(label=paste(type,"-",point)))
As you can see, the E
bar is too high, so I want to remove y axis from 15-95, so I can see the difference of other lower types.
I know there are some thing like scale free x or y in facet_grid
or facet_wrap
, anything like these in a simgle plot like mine?
Upvotes: 0
Views: 583
Reputation: 41
EDIT TO ADD FORMATTING
Does this work for you?
library(scales)
ggplot(data, aes(x=type, y=point, fill="type")) +
geom_bar(stat="identity") +
geom_text(data=data, aes(label=paste(type,"-",point))) +
scale_y_log10(labels = comma)
EDIT 2
OR
If you don't want commas...
ggplot(data, aes(x=type, y=point, fill="type")) +
geom_bar(stat="identity") +
geom_text(data=data, aes(label=paste(type,"-",point))) +
scale_y_log10(labels = format_format(scientific = FALSE))
Upvotes: 3