Hola tod en s, al utilizar 2 gráficos en uno con *par(mfrow=c(1,2)), *solo
deseo poner leyenda por dentro a uno de los gráficos. Lo he hecho, pero
deseo que la leyenda quede mas cerca del borde, ya que al máximizar la
ventana extra x11(), la leyenda sale casi a la mitad del gráfico a pesar de
usar topright con el código legend('topright', legend =
levels(Presas$Season), col = 1:4,
cex = 0.7, pch = 16).
Copio todo el código a continuación. Gracias
x11()
par(mfrow=c(1,2), mar=c(5,5,5,1) + .1)
I.nought = -15.479969
I1 = I.nought + 0
I2 = I.nought + -0.319291
I3 = I.nought + -5.606254
B = 0.051463
plot(x = Presas$Lat,
y = Presas$C,
col = Presas$Season,
pch = 16,
xlab = "Latitude",
ylab = "C")
abline(I1, B,
lty=1, lwd=2, col = 1)
abline(I2, B,
lty=1, lwd=2, col = 2)
abline(I3, B,
lty=1, lwd=2, col = 3)
legend("topleft", c("a"),
inset=c(0,-0.07), xpd=TRUE, horiz=TRUE, bty="n"
)
I.nought = 26.34891
I1 = I.nought + 0
I2 = I.nought + 0.84785
I3 = I.nought + -13.00021
B = -0.13421
plot(x = Presas$Lat,
y = Presas$N,
col = Presas$Season,
pch = 16,
xlab = "Latitude",
ylab = "N")
legend('topright',
legend = levels(Presas$Season),
col = 1:4,
cex = 0.7,
pch = 16)
abline(I1, B,
lty=1, lwd=2, col = 1)
abline(I2, B,
lty=1, lwd=2, col = 2)
abline(I3, B,
lty=1, lwd=2, col = 3)
legend("topleft", c("b"),
inset=c(0,-0.07), xpd=TRUE, horiz=TRUE, bty="n"
)
[R-es] posición leyenda
2 messages · Carmen Guzmán, Carlos Ortega
Hola, Prueba con la función "layout()" con la que puedes definir mejor las zonas de representación de cada elemento. Mejor que con "par()". Gracias, Carlos Ortega www.qualityexcellence.es El jue., 28 may. 2020 a las 17:54, Carmen Guzmán (<guatespain en gmail.com>) escribió:
Hola tod en s, al utilizar 2 gráficos en uno con *par(mfrow=c(1,2)), *solo
deseo poner leyenda por dentro a uno de los gráficos. Lo he hecho, pero
deseo que la leyenda quede mas cerca del borde, ya que al máximizar la
ventana extra x11(), la leyenda sale casi a la mitad del gráfico a pesar de
usar topright con el código legend('topright', legend =
levels(Presas$Season), col = 1:4,
cex = 0.7, pch = 16).
Copio todo el código a continuación. Gracias
x11()
par(mfrow=c(1,2), mar=c(5,5,5,1) + .1)
I.nought = -15.479969
I1 = I.nought + 0
I2 = I.nought + -0.319291
I3 = I.nought + -5.606254
B = 0.051463
plot(x = Presas$Lat,
y = Presas$C,
col = Presas$Season,
pch = 16,
xlab = "Latitude",
ylab = "C")
abline(I1, B,
lty=1, lwd=2, col = 1)
abline(I2, B,
lty=1, lwd=2, col = 2)
abline(I3, B,
lty=1, lwd=2, col = 3)
legend("topleft", c("a"),
inset=c(0,-0.07), xpd=TRUE, horiz=TRUE, bty="n"
)
I.nought = 26.34891
I1 = I.nought + 0
I2 = I.nought + 0.84785
I3 = I.nought + -13.00021
B = -0.13421
plot(x = Presas$Lat,
y = Presas$N,
col = Presas$Season,
pch = 16,
xlab = "Latitude",
ylab = "N")
legend('topright',
legend = levels(Presas$Season),
col = 1:4,
cex = 0.7,
pch = 16)
abline(I1, B,
lty=1, lwd=2, col = 1)
abline(I2, B,
lty=1, lwd=2, col = 2)
abline(I3, B,
lty=1, lwd=2, col = 3)
legend("topleft", c("b"),
inset=c(0,-0.07), xpd=TRUE, horiz=TRUE, bty="n"
)
[[alternative HTML version deleted]]
_______________________________________________ R-help-es mailing list R-help-es en r-project.org https://stat.ethz.ch/mailman/listinfo/r-help-es
Saludos, Carlos Ortega www.qualityexcellence.es [[alternative HTML version deleted]]