0% found this document useful (0 votes)
53 views17 pages

Customizing Your Plots

This document discusses customizing plots in R. It shows how to create basic and fancy plots of mercury temperature and pressure data by adjusting graphical parameters like the x-label, y-label, plot title, point type, color, and font sizes. These parameters can be set globally using par() and for individual plots to customize appearances. A variety of plot types and symbols are demonstrated.

Uploaded by

seggy7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views17 pages

Customizing Your Plots

This document discusses customizing plots in R. It shows how to create basic and fancy plots of mercury temperature and pressure data by adjusting graphical parameters like the x-label, y-label, plot title, point type, color, and font sizes. These parameters can be set globally using par() and for individual plots to customize appearances. A variety of plot types and symbols are demonstrated.

Uploaded by

seggy7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

INTRODUCTION TO R

Customizing
Plots

Introduction to R

mercury
> mercury
temperature pressure
1
0
0.0002
2
20
0.0012
3
40
0.0060
4
60
0.0300
5
80
0.0900
6
100
0.2700
7
120
0.7500
8
140
1.8500
9
160
4.2000
10
180
8.8000
11
200 17.3000
...
19
360 806.0000

Introduction to R

Basic plot
> plot(mercury$temperature, mercury$pressure)

Introduction to R

Fancy plot
> plot(mercury$temperature, mercury$pressure,
horizontal axis label
xlab = "Temperature",
vertical axis label
ylab = "Pressure",
main = "T vs P for Mercury",
plot title
type = "o",
plot type
col = "orange")

Introduction to R

Fancy plot
> plot(mercury$temperature, mercury$pressure,
horizontal axis label
xlab = "Temperature",
vertical axis label
ylab = "Pressure",
main = "T vs P for Mercury",
plot title
type = "l",
plot type
col = "orange")
plot color

Introduction to R

Graphical Parameters
> plot(mercury$temperature, mercury$pressure, col = "darkgreen")

Introduction to R

Graphical Parameters
> plot(mercury$temperature, mercury$pressure)

Introduction to R

par()
> ?par
> par()
List of 72
$ xlog
:
$ ylog
:
$ adj
:
...
$ fin
:
$ font
:
$ font.axis:
$ font.lab :
...
$ yaxs
:
$ yaxt
:
$ ylbias
:

logi FALSE
logi FALSE
num 0.5
num
int
int
int

[1:2] 8.31 6.89


1
1
1

chr "r"
chr "s"
num 0.2

Introduction to R

par()
> par(col = "blue")
> plot(mercury$temperature, mercury$pressure)

Introduction to R

par()
> par(col = "blue")
> plot(mercury$temperature, mercury$pressure)
> plot(mercury$pressure, mercury$temperature)
> par()$col
[1] "blue"

Introduction to R

More graphical parameters


> plot(mercury$temperature, mercury$pressure,
xlab = "Temperature",
ylab = "Pressure",
main = "T vs P for Mercury",
type = "o",
col = "orange",
col.main = "darkgray",
cex.axis = 0.6,
lty = 5,
pch = 4)

Introduction to R

More graphical parameters


> plot(mercury$temperature, mercury$pressure,
xlab = "Temperature",
ylab = "Pressure",
main = "T vs P for Mercury",
type = "o",
col = "orange",
col.main = "darkgray",
cex.axis = 0.6,
lty = 5,
pch = 4)

Introduction to R

More graphical parameters


> plot(mercury$temperature, mercury$pressure,
xlab = "Temperature",
ylab = "Pressure",
main = "T vs P for Mercury",
type = "o",
col = "orange",
col.main = "darkgray",
cex.axis = 0.6,
lty = 5,
pch = 4)

Introduction to R

More graphical parameters


> plot(mercury$temperature, mercury$pressure,
xlab = "Temperature",
ylab = "Pressure",
main = "T vs P for Mercury",
type = "o",
col = "orange",
col.main = "darkgray",
cex.axis = 1.5,
lty = 5,
pch = 4)

Introduction to R

lty: Line Type


> plot(mercury$temperature, mercury$pressure,
xlab = "Temperature",
ylab = "Pressure",
main = "T vs P for Mercury",
type = "o",
col = "orange",
col.main = "darkgray",
cex.axis = 1.5,
lty = 5,
pch = 4)

Introduction to R

pch: Plot Symbol


> plot(mercury$temperature, mercury$pressure,
xlab = "Temperature",
ylab = "Pressure",
main = "T vs P for Mercury",
type = "o",
col = "orange",
col.main = "darkgray",
cex.axis = 1.5,
lty = 5,
pch = 4)

INTRODUCTION TO R

Lets practice!

You might also like