[R-es] problema con grafico lattice ....
Carlos Ortega
cof en qualityexcellence.es
Sab Ene 21 01:24:38 CET 2017
Hola,
Por si lo quieres con colores rellenando cada punto:
#----------------
library(data.table)
library(lattice)
dat <- read.table("pba.csv", header=TRUE, dec=",", as.is=TRUE)
row.names(dat) <- NULL
dat <- as.data.table(dat)
dat$mycol <- ifelse(dat$sol =="ControlAE", "red", dat$sol)
dat$mycol <- ifelse(dat$mycol =="ControlAB", "blue", dat$mycol)
dat$mycol <- ifelse(dat$mycol =="Biodiesel", "tomato", dat$mycol)
dat$mycol <- ifelse(dat$mycol =="Decane", "black", dat$mycol)
dat$mypch <- ifelse(dat$sol =="ControlAE", 21, dat$sol)
dat$mypch <- ifelse(dat$mypch =="ControlAB", 22, dat$mypch)
dat$mypch <- ifelse(dat$mypch =="Biodiesel", 23, dat$mypch)
dat$mypch <- ifelse(dat$mypch =="Decane", 24, dat$mypch)
dat <- as.data.frame(dat)
dat <- dat[dat$con!=0,]
xyplot(mean ~ con
,groups = sol
,data = dat
,xlab=list("Solvent concentration (%v/v)", cex=1.2)
,ylab=list("Contact angle (º)", cex=1.2)
,col = "black"
,cex = 2
,ylim=c(70,140)
,fill_col = dat$mycol
,el_pch = as.numeric(dat$mypch)
,panel = function(x, y, fill_col,el_pch,groups,...,subscripts) {
fill <- fill_col[subscripts]
pch <- el_pch[subscripts]
panel.xyplot(x, y, pch = pch, fill = fill, ...)
panel.abline(h=c(103.141,101.779), lty=c(3,2))
}
)
#----------------
[image: Imágenes integradas 1]
El 21 de enero de 2017, 0:24, Carlos Ortega <cof en qualityexcellence.es>
escribió:
> Hola,
>
> Este es el código que produce el gráfico que envié...
>
> #---------------------------
> library(data.table)
> library(lattice)
>
> dat <- read.table("pba.csv", header=TRUE, dec=",", as.is=TRUE)
> row.names(dat) <- NULL
> dat <- as.data.table(dat)
>
> #trellis.device(color=FALSE)
> dat[con!=0, xyplot(mean ~ con
> , groups=sol
> , xlab=list("Solvent concentration (%v/v)", cex=1.2)
> , ylab=list("Contact angle (º)", cex=1.2)
> , ylim=c(70,140)
> , scales=list(cex=1.1)
> , cex=1.2
> , panel=function(x,y){
> panel.xyplot(x,y,cex=1.3, pch=c(1,2),
> col=c('red','blue'))
> panel.abline(h=c(103.141,101.779), lty=c(3,2))
> }
> )]
>
> #-------------------
>
> Con trellis.device(color = FALSE) simplemente abres una nueva ventana sin
> color de fondo.
> Para ver el motivo de la superposición de los puntos que te ocurre,
> tendría que ver tu código.
>
> Gracias,
> Carlos
>
> El 20 de enero de 2017, 18:39, eric <ericconchamunoz en gmail.com> escribió:
>
>> mmmm, no puedo encontrar el motivo, pero al usar el codigo que envie me
>> sale el grafico que adjunto, con los simbolos sobrepuestos.
>>
>> Alguna idea de por donde mirar ?
>>
>> gracias,
>>
>> Eric.
>>
>>
>>
>>
>>
>>
>> On 01/20/2017 09:36 AM, Carlos Ortega wrote:
>>
>>> Hola,
>>>
>>> A mi me salen diferentes...
>>> Imágenes integradas 1
>>> Y puedo definir también dos colores...
>>>
>>> Saludos,
>>> Carlos Ortega
>>> www.qualityexcellence.es <http://www.qualityexcellence.es>
>>>
>>>
>>>
>>> El 20 de enero de 2017, 5:04, eric <ericconchamunoz en gmail.com
>>> <mailto:ericconchamunoz en gmail.com>> escribió:
>>>
>>> Estimada comunidad, estoy tratando de hacer un grafico y no resulta
>>> (adjuntos datos). Se grafican la vble "con" en el eje X y "can" en
>>> el eje Y. Se agrupa por la vble "sol". Se deben agregar como lineas
>>> horizontales los valores de "can" asociados a "sol" "ControlAE" y
>>> "ControlAB", para lo que uso panel.
>>>
>>> Pero al agregar panel los simbolos que identifican a cada uno de los
>>> dos grupos de datos se vuelven el mismo.
>>>
>>> Al usar pch=c() para tratar de usar dos simbolos diferentes NO pasa
>>> nada ... alguna sugerencia ?
>>>
>>> adjunto codigo y datos .... gracias,
>>>
>>> eric.
>>>
>>>
>>>
>>> dat[con!=0, xyplot(mean ~ con
>>> , groups=sol
>>> , xlab=list("Solvent concentration (%v/v)", cex=1.2)
>>> , ylab=list("Contact angle (º)", cex=1.2)
>>> , ylim=c(70,140)
>>> , scales=list(cex=1.1)
>>> , cex=1.2
>>> , panel=function(x,y){
>>> panel.xyplot(x,y,cex=1.3, pch=c(1,2))
>>> panel.abline(h=c(103.141,101.779), lty=c(3,2))
>>> }
>>> )]
>>>
>>>
>>>
>>> _______________________________________________
>>> R-help-es mailing list
>>> R-help-es en r-project.org <mailto:R-help-es en r-project.org>
>>> https://stat.ethz.ch/mailman/listinfo/r-help-es
>>> <https://stat.ethz.ch/mailman/listinfo/r-help-es>
>>>
>>>
>>>
>>>
>>> --
>>> Saludos,
>>> Carlos Ortega
>>> www.qualityexcellence.es <http://www.qualityexcellence.es>
>>>
>>
>> --
>> Forest Engineer
>> Master in Environmental and Natural Resource Economics
>> Ph.D. student in Sciences of Natural Resources at La Frontera University
>> Member in AguaDeTemu2030, citizen movement for Temuco with green city
>> standards for living
>>
>> Nota: Las tildes se han omitido para asegurar compatibilidad con algunos
>> lectores de correo.
>>
>
>
>
> --
> Saludos,
> Carlos Ortega
> www.qualityexcellence.es
>
--
Saludos,
Carlos Ortega
www.qualityexcellence.es
------------ próxima parte ------------
Se ha borrado un adjunto en formato HTML...
URL: <https://stat.ethz.ch/pipermail/r-help-es/attachments/20170121/147781fd/attachment-0001.html>
------------ próxima parte ------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 22916 bytes
Desc: no disponible
URL: <https://stat.ethz.ch/pipermail/r-help-es/attachments/20170121/147781fd/attachment-0001.png>
Más información sobre la lista de distribución R-help-es