R: Lattice How to remove white space between bars and x axis?

。_饼干妹妹 提交于 2019-12-11 06:50:38

问题


I am new to R and am using lattice to create a clustered bar graph. I wrote the following code.

nature <- read.table(text = "Nature_of_recreation, Familiarity_with_the_partner, Count
Danced, Not familiar at all, 21
Danced, Not very familiar, 22
Danced, Very familiar, 22
Sketched, Not familiar at all, 6
Sketched, Not very familiar, 17
Sketched, Very familiar, 16
Dined, Not familiar at all, 16
Dined, Not very familiar, 14
Dined, Very familiar, 10
Swimmed, Not familiar at all, 6
Swimmed, Not very familiar, 15
Swimmed, Very familiar, 11
Played, Not familiar at all, 1
Played, Not very familiar, 6
Played, Very familiar, 7
Dreamed, Not familiar at all, 5
Dreamed, Not very familiar, 17
Dreamed, Very familiar, 10",
                     header = TRUE, sep = ",")
colors = c("lightsalmon3", "lightgoldenrod2", "cadetblue4")
lattice::barchart(data = nature, origin = 0, Count ~ Nature_of_recreation,
                  groups = Familiarity_with_the_partner, 
                  xlab = list(label = "Nature of recreation", font = 2, cex = 1),
                  ylab= list (label = "Number of students", font = 2, cex = 1),
                  labels = TRUE, auto.key = list(space="top", columns= 3),
                  par.settings = list(superpose.polygon = list(col = colors)))

The output looks all good, except:

  1. It has a white space in between bars and the X-axis.
  2. It does not have values displayed on top of each bar.

Can anyone please help me fix these issues?

来源:https://stackoverflow.com/questions/45222720/r-lattice-how-to-remove-white-space-between-bars-and-x-axis

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!