Please consider the following
library(ggplot)
data <- data.frame(qnt=c(10,20,22,12,14,9,1000),lbl=c("A","B","C","D","E","F","G"))
ggplot(data=data, aes(x=lbl, y=qnt)) + geom_histogram(stat="identity")
which produces
Which options should I consider to truncate the highest bar G
in the plot? (of course explaining to the viewer what I did)
If you want to fiddle with it, you can use the gridExtra
package, and plot 2 (or more) trimmed out sections of the graph. I've tinkered with the margins to make it line up, but a better plan would probably be to format the axis labels to the same text width,
require(ggplot2)
require(gridExtra)
data <- data.frame(qnt=c(10,20,22,12,14,9,1000),lbl=c("A","B","C","D","E","F","G"))
g1<-ggplot(data=data, aes(x=lbl, y=qnt)) +
geom_histogram(stat="identity")+
coord_cartesian(ylim=c(-10,50)) +
labs(x=NULL, y=NULL)+
theme(plot.margin=unit(c(2,2,6,3),"mm"))
g2<-ggplot(data=data, aes(x=lbl, y=qnt)) +
geom_histogram(stat="identity") +
coord_cartesian(ylim=c(990,1010)) +
theme(axis.text.x = element_blank(),
axis.title.x = element_blank(),
axis.title.y = element_blank(),
axis.ticks.x = element_blank()) +
labs(x=NULL, y=NULL) +
theme(plot.margin=unit(c(5,2,0,0),"mm"))
grid.arrange(g2,g1, heights=c(1/4, 3/4), ncol=1, nrow=2)
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