在过去的几周里,我一直在使用ggplot2,并且想知道是否有人可以帮助我解决我遇到的这个问题.
当我绘制我的盒子图时,我的盒子互相接触.我希望他们之间有一点空间.有没有办法实现这个目标?我确信有,我只是没有看到它.
弯曲你的RCurl/XML肌肉.最短的代码获胜.解析为R:http://pastebin.com/CDzYXNbG
数据应该是:
structure(list(Treatment = structure(c(2L, 2L, 1L, 1L), .Label = c("C",
"T"), class = "factor"), Gender = c("M", "F", "M", "F"), Response = c(56L,
58L, 6L, 63L)), .Names = c("Treatment", "Gender", "Response"), row.names = c(NA,
-4L), class = "data.frame")
Run Code Online (Sandbox Code Playgroud)
祝好运!
注意:此问题提供的虚拟数据:在ggplot2中的条形之间添加空格
我有一个条形图:
p <- ggplot(data=df, aes(x=Gene, y=FC, fill=expt, group=expt))
p <- p + geom_bar(colour="black", stat="identity", position = position_dodge(width = 0.9))
p <- p + geom_errorbar(aes(ymax = FC + se, ymin = FC, group=expt),
position = position_dodge(width = 0.9), width = 0.25)
p
Run Code Online (Sandbox Code Playgroud)
我想增加条之间的间距(对于每个bin).我已经尝试过乱搞position_dodge(width = ...)但是它会使我的误差条偏斜:

还有其他一些与此相关的问题:

即它似乎增加了箱之间,但代价是与相邻的酒吧重叠
假设我想制作直方图
所以我使用以下代码
v100<-c(runif(100))
v100
library(ggplot2)
private_plot<-ggplot()+aes(v100)+geom_histogram(binwidth = (0.1),boundary=0
)+scale_x_continuous(breaks=seq(0,1,0.1), lim=c(0,1))
private_plot
Run Code Online (Sandbox Code Playgroud)
如何将我的色谱柱分开,使整个物体更加悦目?
我试过这个,但它不知何故不起作用:
谢谢
[在帖子末尾生成情节的数据和代码]
使用ggplot,我绘制了带有误差线的条形图,条按两个因素分组(一个在X轴上,一个在填充)。我想增加x轴上各组之间的绿色距离,以使图更易于阅读:

我在这里找到了与stackoverflow解决方案最接近的东西(有人在一个未答复的评论中问了我的问题),在这里,这里,但是我没有设法在不增加错误栏的情况下应用这些东西。有人可以指出我要调整的正确参数吗?
数据:
structure(list(Condition = c("Difficult", "Easy", "Difficult",
"Easy", "Difficult", "Easy", "Difficult", "Easy", "Easy", "Difficult",
"Easy", "Difficult"), Measure = c("Competence", "Competence",
"Value", "Value", "Interest", "Interest", "JOL", "JOL", "Difficulty",
"Difficulty", "Effort", "Effort"), mean = c(5.5, 4.72, 4.04,
5.39, 3.51, 3.77, 4.34, 4.61, 3.51, 1.51, 3.44, 1.73), sd = c(1.26,
1.62, 1.94, 1.34, 1.46, 1.46, 1.73, 1.68, 1.5, 0.86, 1.53, 1.1
), se = c(0.14, 0.18, 0.22, 0.15, 0.16, 0.16, 0.19, …Run Code Online (Sandbox Code Playgroud) 我有如下数据:
library(data.table)
library(ggplot2)
library(dplyr)
library(tidyverse)
library(ggsignif)
graph <- structure(list(Constraint = structure(c(4L, 2L, 3L, 1L, 5L, 4L,
2L, 3L, 1L, 5L), .Label = c("Major Constraint", "Minor Constraint",
"Moderate Constraint", "No Constraint", "Total"), class = "factor"),
`Observation for Crime = 0` = c(3124, 2484, 3511, 4646, 13765,
3124, 2484, 3511, 4646, 13765), `Observation for Crime = 1` = c(762,
629, 1118, 1677, 4186, 762, 629, 1118, 1677, 4186), `Total Observations` = c(3886,
3113, 4629, 6323, 17951, 3886, 3113, 4629, 6323, 17951),
variable …Run Code Online (Sandbox Code Playgroud)