Está en la página 1de 10

¡Ahorre un 75% en una suscripción anual ahora y donaremos una!

La oferta termina en 4 dias dieciséis horas 46 minutos 54 segundos

RDocumentación Busque paquetes, funciones, etc.

trama 99,99
Desde grá cos v3.6.2
por R-core R-core@R-project.org Percentil

Trazado XY Genérico

Función genérica para el trazado de objetos R. Para obtener más detalles sobre los argumentos de
los parámetros grá cos, consulte par .

Para diagramas de dispersión simples, plot.default se utilizará. Sin embargo, existen plot
métodos para muchos objetos R , incluidos function s, data.frame s, density objetos, etc. Utilice
methods(plot) y la documentación para estos.

Palabras clave hplot

Uso

plot(x, y, …)

Argumentos

X las coordenadas de los puntos en el grá co. Alternativamente, se puede


proporcionar una única estructura de trazado, función o cualquier objeto R con un
plot método .

y las coordenadas y de los puntos en el grá co, opcional si x es una estructura


apropiada.

... Argumentos que se pasarán a métodos, como parámetros grá cos (ver par ).
Muchos métodos aceptarán los siguientes argumentos:

type qué tipo de trama se debe dibujar. Los tipos posibles son

"p" de p UNTOS,

"l" para l ines,

"b" para b OTH,

"c" para las líneas solo parte de "b" ,

"o" por tanto ' o verplotted',


 Documentación
Pon aAPI Creado porde
prueba tus habilidades DataCamp.com
R Empezar ahora 
"h" para líneas verticales como ' h istograma' (o 'alta
densidad'),

"s" para escaleras s teps,

"S" para otros s PTE véase 'Detalles' a continuación,

"n" para no trazar.

Todos los demás type mensajes dan una advertencia o un error;


utilizando, por ejemplo, type = "punkte" ser equivalente a
type = "p" para compatibilidad S. Tenga en cuenta que algunos
métodos, por ejemplo plot.factor , no aceptan esto.

main un título general para la trama: ver title .

sub un subtítulo para la trama: ver title .

xlab un título para el eje x: ver title .

ylab un título para el eje y: ver title .

asp la y/Xrelación de aspecto, consulte plot.window .

Detalles

Los dos tipos de pasos di eren en su preferencia xy: yendo de a con , se mueve primero
horizontalmente, luego vertical, mientras que se mueve al revés.(X1, y1)(X2, y2)X1 < X2

type = "s" type = "S"

Ver También

plot.default , plot.formula Y otros métodos; points , lines , par . Para miles de puntos,
considere usar en smoothScatter() lugar de plot() .

Para el trazado XYZ contour , consulte , persp y image .

Ejemplos
script.R R Console
1 # NOT RUN { >
2 require(stats) # for lowess, rpois, rn
3 plot(cars)
4 lines(lowess(cars))
5
6 plot(sin, -pi, 2*pi) # see ?plot.funct
7
8 ## Discrete Distribution Plot:
9 plot(table(rpois(100, 5)), type = "h",
10 main = "rpois(100, lambda = 5)")
11 Documentación API Creado porde
DataCamp.com
 Pon a prueba tus habilidades R Empezar ahora 
12 ## Simple quantiles/ECDF, see ecdf() {
one:
13 plot(x <- sort(rnorm(47)) type = "s"

Run 

Powered by DataCamp
Documentation reproduced from package graphics, version 3.6.2, License: Part of R 3.6.2

Community examples

Luis Alberto at Sep 4, 2019 graphics v3.6.1

plot(basedata1$iq, basedata$read_ab, main="Diagrama de Dispersión", xlab = "read_ab", yla

richie@datacamp.com at Jan 17, 2017 graphics v3.3.2

Pass a numeric vector to the `x` and `y` arguments, and you get a scatter plot. The `mai

script.R R Console
1 plot(1:100, (1:100) ^ 2, main = "plot( >

Run 

Powered by DataCamp
If you only pass a single argument, it is interpreted as the y argument, and the x argument is the
sequence from 1 to the length of y .

script.R R Console
1 plot((1:100) ^ 2, main = "plot((1:100) >

 Documentación
Pon aAPI Creado porde
prueba tus habilidades DataCamp.com
R Empezar ahora 
Run 

Powered by DataCamp
cex ("character expansion") controls the size of points.
lwd controls the line width.
pch controls the shape of points - you get 25 symbols to choose from, as well as alphabetic characters.
col controls the color of the points.
When pch is 21:25 , the points also get a background color which is set using bg .
points() for more on how to change the appearance of points in a scatter plot.

script.R R Console
1 plot( >
2 1:25,
3 cex = 3,
4 lwd = 3,
5 pch = 1:25,
6 col = rainbow(25),
7 bg = c(rep(NA, 20), terrain.color
8 main = "plot(1:25, pch = 1:25, ...)
9 )

Run 

Powered by DataCamp
If you specify type = "l" , you get a line plot instead. See plot.default() for a demonstration of all the
possible values for type.

script.R R Console
1 plot( >
2 (1:100) ^ 2,
3 type = "l",
4 main = 'plot((1:100) ^ 2, type = "l"
5 )

Run 

Documentación
Powered Pon aAPI
by DataCamp Creado porde
prueba tus habilidades DataCamp.com
R Empezar ahora 
lty controls the line type. col and lwd work in the same way as with points.
lines() for more on how to change the appearance of lines in a line plot.

script.R R Console
1 plot( >
2 (1:100) ^ 2,
3 type = "l",
4 lty = "dashed",
5 lwd = 3,
6 col = "chocolate",
7 main = 'plot((1:100) ^ 2, type = "l"
8 )

Run 

Powered by DataCamp
It is best practise to keep your x and y variables together, rather than as separate variables.

script.R R Console
1 with( >
2 cars,
3 plot(speed, dist, main = "with(cars,
4 )

Run 

Powered by DataCamp
The formula interface, similar to modeling functions like lm() , makes this convenient. See
plot.formula() for more information.

script.R R Console
1 plot( >
2 dist ~ speed,
3 data = cars,
4 main = "plot(dist ~ speed, data = ca
5 )

 Documentación
Pon aAPI Creado porde
prueba tus habilidades DataCamp.com
R Empezar ahora 
Run 

Powered by DataCamp
If you pass a two column data frame or matrix then the columns are treated as the x and y values. So in
this case, you can simply do:

script.R R Console
1 plot(cars, main = "plot(cars)") >

Run 

Powered by DataCamp
The lines() , points() and title() functions add lines, points and titles respectively to an existing
plot.

script.R R Console
1 plot(cars) >
2 lines(lowess(cars))
3 title("plot(cars); lines(lowess(cars))

Run 

Powered by DataCamp
If the x variable is categorical, plot() knows to draw a box plot instead of a scatter plot. See
boxplot() for more information on drawing those.

script.R R Console
1 with( >
2 sleep,
3 plot(group, extra, main = "with(slee
4 )
 Documentación
Pon aAPI Creado porde
prueba tus habilidades DataCamp.com
R Empezar ahora 
Run 

Powered by DataCamp
Again, the formula interface can be useful here.

script.R R Console
1 plot(extra ~ group, sleep, main = "plo >

Run 

Powered by DataCamp
Axis limits can be set using xlim and ylim .

script.R R Console
1 plot( >
2 (1:100) ^ 2,
3 xlim = c(-100, 200),
4 ylim = c(2500, 7500),
5 main = "plot((1:100) ^ 2, xlim = c(-
))"
6 )

Run 

Powered by DataCamp
You can set log-scale axes using the log argument.

script.R R Console
1 plot( >
 Documentación
2 Pon aAPI
exp(1:10), Creado porde
prueba tus habilidades DataCamp.com
R Empezar ahora 
3 2 ^ (1:10),
4 main = "plot(exp(1:10), 2 ^ (1:10
5 )
6 plot(
7 exp(1:10),
8 2 ^ (1:10),
9 log = "x",
10 main = 'plot(exp(1:10), 2 ^ (1:10
11 )
12 plot(
13 exp(1:10),
14 2 ^ (1:10),

Run 

Powered by DataCamp
If you pass a table of counts for a vector, plot() draws a simple histogram-like plot. See hist() for a
more comprehensive histogram function.

script.R R Console
1 plot( >
2 table(rpois(100, 5)),
3 main = "plot(table(rpois(100, 5)))"
4 )

Run 

Powered by DataCamp
For multi-dimensional tables, you get a mosaic plot. See mosaicplot() for more information.

script.R R Console
1 plot( >
2 table(X = rpois(100, 5), Y = rbinom(
3 main = "plot(table(X = rpois(100, 5)
4 )

Run 

Powered by DataCamp
You can also pass functions to plot. See curve() for more examples.
 Documentación
Pon aAPI Creado porde
prueba tus habilidades DataCamp.com
R Empezar ahora 
script.R R Console
1 plot( >
2 sin,
3 from = -pi,
4 to = 2 * pi,
5 main = "plot(sin, from = -pi, to = 2
6 )

Run 

Powered by DataCamp
Use the axis function to give fine control over how the axes are created. See axis() and Axis() for
more info.

script.R R Console
1 plot( >
2 sin,
3 from = -pi,
4 to = 2 * pi,
5 axes = FALSE,
6 main = "plot(sin, axes = FALSE, ...
7 )
8 axis(
9 1, # bottom axis
10 pi * (-1:2),
11 c(expression(-pi), 0, expression(pi
12 )
13 axis(2) # left axis

Run 

Powered by DataCamp
Further graphical parameters can be set using par() . See with_par() for the best way to use par() .

script.R R Console
1 old_pars <- par(las = 1) # horizontal >
2 plot((1:100) ^ 2, main = "par(las = 1)
3 par(old_pars) # reset param

 Documentación Creado porde


DataCamp.com
Run  Pon aAPI
prueba tus habilidades R Empezar ahora 
Powered by DataCamp

Publica un nuevo ejemplo:

  |   |     |   | | 

## New example
Use markdown to format your example

R code blocks are runnable and interactive:


```r
a <- 2
print(a)
```

You can also display normal code blocks


```
var a = b
```

Envíe su ejemplo

 Documentación
Pon aAPI Creado porde
prueba tus habilidades DataCamp.com
R Empezar ahora 

También podría gustarte