Reputation: 2596
I want to plot some data in R.
the table look like:
Name Count
A 110
B 120
C 130
I want to plot this table which each column is Name
and the bar height is Count
. I also want to zoom to important part from 100 to 150 because all values in Count
is greater than 100.
I think we could set the y-axis base to 100 in this case. Hope someone can help.
Upvotes: 0
Views: 2054
Reputation: 887891
Try
m1 <- matrix(df1[,2], ncol=3, dimnames=list(NULL, df1[,1]))
barplot(m1, ylim=c(100,150), beside=TRUE, xpd=FALSE)
Or
library(ggplot2)
ggplot(df1, aes(x=Name, y=Count))+
geom_bar(stat='identity')+
coord_cartesian(ylim=c(100,150)) +
theme_bw() +
xlab(NULL) +
ylab(NULL)
df1 <- structure(list(Name = c("A", "B", "C"), Count = c(110L, 120L,
130L)), .Names = c("Name", "Count"), class = "data.frame",
row.names = c(NA, -3L))
Upvotes: 4