- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我遇到了无法解决的 ggplot 问题,所以也许这里有人可以指出原因。抱歉,我无法上传我的数据集,但可以在下面找到一些数据描述。 ggplot 的输出如下所示,除了 NO 行,其他一切正常。
> all.data<-read.table("D:/PAM/data/Rural_Recovery_Edit.csv",head=T,sep=",")
> all.data$Water<-factor(all.data$Water,labels=c("W30","W60","W90"))
> all.data$Polymer<-factor(all.data$Polymer,labels=c("PAM-0 ","PAM-10 ","PAM-40 "))
> all.data$Group<-factor(all.data$Group,labels=c("Day20","Day25","Day30"))
> dat<-data.frame(Waterconsump=all.data[,9],Water=all.data$Water,Polymer=all.data$Polymer,Age=all.data$Group)
> ggplot(dat,aes(x=Water,y=Waterconsump,colour=Polymer))+
+ stat_summary(fun.y=mean, geom="line",size=2)+
+ stat_summary(fun.ymin=min,fun.ymax=max,geom="errorbar")+#,position="dodge"
+ facet_grid(~Age)
> dim(dat)
[1] 108 4
> head(dat)
Waterconsump Water Polymer Age
1 10.5 W30 PAM-10 Day20
2 10.3 W30 PAM-10 Day20
3 10.1 W30 PAM-10 Day20
4 7.7 W30 PAM-10 Day20
5 8.6 W60 PAM-10 Day20
6 8.4 W60 PAM-10 Day20
> table(dat$Water)
W30 W60 W90
36 36 36
> table(dat$Polymer)
PAM-0 PAM-10 PAM-40
36 36 36
> table(dat$Age)
Day20 Day25 Day30
36 36 36
below is the background for this Q
library(reshape)
library(agricolae)
library(lattice)
yr<-gl(10,3,90:99)
trt<-gl(4,75,labels=c("A","B","C","D"))
third<-gl(3,100,lables=c("T","P","Q")) ### The third factor to split the figure in to 4 subplots
dat<-cbind(runif(300),runif(300,min=1,max=10),runif(300,min=100,max=200),runif(300,min=1000,max=1500))
colnames(dat)<-paste("Item",1:4,sep="-")
fac<-factor(paste(trt,yr,sep="-"))
dataov<-aov(dat[,1]~fac)
dathsd<-sort_df(HSD.test(dataov,'fac'),'trt')
trtplt<-gl(3,10,30,labels=c("A","B","C"))
yrplt<-factor(substr(dathsd$trt,3,4))
prepanel.ci <- function(x, y, ly, uy, subscripts, ...)
{
x <- as.numeric(x)
ly <- as.numeric(ly[subscripts])
uy <- as.numeric(uy[subscripts])
list(ylim = range(y, uy, ly, finite = TRUE))
}
panel.ci <- function(x, y, ly, uy, subscripts, pch = 16, ...)
{
x <- as.numeric(x)
y <- as.numeric(y)
ly <- as.numeric(ly[subscripts])
uy <- as.numeric(uy[subscripts])
panel.arrows(x, ly, x, uy, col = "black",
length = 0.25, unit = "native",
angle = 90, code = 3)
panel.xyplot(x, y, pch = pch, ...)
}
xyplot(dathsd$means~yrplt,group=trtplt,type=list("l","p"),
ly=dathsd$means-dathsd$std.err,
uy=dathsd$means+dathsd$std.err,
prepanel = prepanel.ci,
panel = panel.superpose,
panel.groups = panel.ci
)
最佳答案
这是另一种方法,使用 ggplot
的魔力。 .因为 ggplot 会为你计算摘要,我怀疑这意味着你可以跳过做 aov
的整个步骤。 .
关键是你的数据应该是单一的data.frame
您可以传递给 ggplot
.请注意,我创建了新的示例数据来演示。
library(ggplot2)
df <- data.frame(
value = runif(300),
yr = rep(1:10, each=3),
trt = rep(LETTERS[1:4], each=75),
third = rep(c("T", "P", "Q"), each=100)
)
ggplot(df, aes(x=yr, y=value, colour=trt)) +
stat_summary(fun.y=mean, geom="line", size=2) +
stat_summary(fun.ymin=min, fun.ymax=max, geom="errorbar") +
facet_grid(~third)
ggplot(df, aes(x=yr, y=value, colour=trt)) +
stat_summary(fun.y=mean, geom="line", size=2) +
stat_summary(fun.ymin=min, fun.ymax=max, geom="errorbar") +
facet_grid(trt~third)
关于r - 使用 xyplot 进行三因子绘图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5692428/
我正在尝试使用 android studio 3.5 来熟悉 android XYPlot。我首先测试了几个例子,最后得到了同样的错误 - Caused by: android.view.Inflat
下面是我在仅以单个变量为条件时使用的代码。如下所示使用 index.cond 可以切换最终图表中面板的顺序。但是,现在我以两个变量为条件,下面的代码无法切换不同面板的位置。我如何修改 index.co
我已经加载了lattice包。然后我运行: > xyplot(yyy ~ xxx | zzz, panel = function(x,y) { panel.lmline(x,y)} 这会生成绘图面板,
我想使用 r 的 lattice 包叠加直方图和表示累积分布函数的 xyplot。 我曾尝试使用自定义面板功能来完成此操作,但似乎无法正确处理——我被一个单变量的图和一个双变量的图挂断了。 这是我想要
我遇到了无法解决的 ggplot 问题,所以也许这里有人可以指出原因。抱歉,我无法上传我的数据集,但可以在下面找到一些数据描述。 ggplot 的输出如下所示,除了 NO 行,其他一切正常。 > al
我用格子创建了一个 xyplot library(lattice) X1=c(5, -2, 1, -3) X2=X1^2 names=paste("dot", 1:4, sep="") xyplot(
R 按字母顺序(对于字符串)或级别顺序(对于因子)确定 xyplot() 中的面板顺序。我有日期作为文本,我想按时间顺序显示,而不是按字母顺序显示。 x <- sample(1:10, 10, rep
现在我有这张图表:http://i.stack.imgur.com/xyyNX.png 我想显示垂直网格。我不知道该怎么做。如果可能,我也想替换虚线。 这是我用来绘制的代码(忽略不相关的部分,例如实际
我想在格子中的单个面板上叠加多个组,并且想要独立的回归线。 获得多个面板相当容易,每个面板都有一条使用条件因子的回归线: xyplot( Petal.Width ~ Petal.Length |
我在数据框上使用 xyplot,并且想要向面板函数提供不是 (x,y, ...) 参数的数据,而是数据框的一些附加列(例如下面示例中的 k) ): library(lattice) mydata <-
当我在重新排序因子之前使用线连接制作 xyplot 时,它为我提供了数据点之间良好的顺序连接: library(lattice) fin <- read.csv("http://dl.dropbox.
我试图改变 strip 的背景颜色(它是一个 6 x 6 矩阵,我有 6 个 strip 颜色存储在名为 cola 的向量中)。我尝试结合在互联网上找到的东西,但我得到的结果完全偏离了目标:现在我得到
我正在尝试使用 xYplot from package Hmisc 绘制覆盖在抖动原始数据点上的误差线。使用panel.stripplot 调用xYplot 中的函数似乎很简单。它可以工作,但有一个奇
考虑一个具有 relation='fixed'、alternating=FALSE 和 as.table=TRUE< 的晶格 xyplot/。 如果最后一行面板不完整(即面板数量少于布局的列数量),则
我正在使用 jfreechart,我需要向我的系列数据添加标签。图形上有粗体点,需要标签...以下代码不起作用。 XYSeries series = new XYSeries("Average
我的绘图(使用 xyplot、lattice)看起来像: 看起来不错,但是如何控制灰色面板框的高度呢? 我试过: strip=strip.custom( par.strip.text=list(cex
我正在尝试重现 this plot : 它看起来像库格子中的 xyplot,但我找不到将马赛克图与 xyplot 组合的方法。 有人知道怎么做吗? 最佳答案 你只是在寻找内置于 vcd:::cotab
我有一个“长”数据框定义为: q <- data.frame(Indicator.Code=factor(),Year=numeric(),Value=numeric()) 并且我试图在单个 xypl
大约一年以来,我一直在使用 AndroidPlot 在我的应用程序中显示不同的图表。现在我正在使用 BarCharts,图表已经完成,但我怎样才能使角变圆? 我找到了一些关于线条的结果: How to
我想将点的形状设置为圆形。我是这样做的: Shape shape = new Ellipse2D.Double(-5,-5,5,5); renderer.setSeriesShape(0, sha
我是一名优秀的程序员,十分优秀!