当前位置: 动力学知识库 > 问答 > 编程问答 >

r - Grouped Bar Plot Species and plots

问题描述:

Id like to make a grouped barplot that has two groups. One named Exotic Species and the second Native Species. then compare them to the Plot that they are found.Therefore 3 columns are involved with the graph. Y would be "Species Richness" and it would be the number of species either of native or exotic. X will be the "Plot name". How do i write out the coding for the bar graph i described above? If you google search European Parliament Elections R grouped barplot (orange and purply plot. thats what i want

网友答案:

If I understand your question correctly you want something like this:

Here is two solutions:

1.using barplot: let's say mtcars is the dataframe

# Grouped Bar Plot
counts <- table(mtcars$vs, mtcars$gear)
barplot(counts, main="Car Distribution by Gears and VS",
  xlab="Number of Gears", col=c("darkblue","red"),
    legend = rownames(counts), beside=TRUE)

Link

  1. using lattice

    library(lattice) barchart(Species~Reason,data=Reasonstats,groups=Catergory, scales=list(x=list(rot=90,cex=0.8)))

Link

分享给朋友:
您可能感兴趣的文章:
随机阅读: