par(mfrow=c(1,1),mar=c(3,0,2,0))
x <- rep(1:8)
y <- rep(1, times = 8)
plot(x,y, col= 1:8, pch= 15, cex= 3, ylim= c(0,2), yaxt= "n",
main= "Colour Numbers in R: 'col = 1 to 8'")
## Defining Symbols (Points)
# default point types by number
pch= 1 # circle outline
pch= c(1,2,3) # vector of points 1,2,3
pch= c(1:3) # range of points 1 to 3 - same as above
# setting points as characters
pch= "A"
pch= c("N","S","E","W")
# point size (cex)
pch= 1
cex= 0.5 # circle outline, 50% the default size
pch= c(1,2,3)
cex= 1.2 # points 1,2,3, all 20% larger than default
# add colour (col,bg)
pch= 1
col= 4 # blue circle outline
pch= 21
col= 3
bg= 1 # filled green circle with black outline
# combine parameters
# points 1,2,5 all 20% larger, and using colours 2 to 4
pch= c(1,2,5)
cex= 1.2
col= c(2:4)
# the most common situation for changing the points is for a scatter plot.
# For example:
with(mtcars, plot(gear ~ disp, pch= 21, cex= 1, col=3, bg=9))
# line type
lty= 1 # solid line
lty= c(1,5,3) # list of lines 1,5,3
lty= c(1:6) # range of points 1 to 3 - same as above
# line width
lty= 1
lwd= 0.5 # solid lines, 50% default size
lty= c(1,2,3)
lwd= 1.2 # lines 1,2,3, all 20% larger
# add colour
lty= 1
col= 4 # blue solid line
lty= c(1,5)
col= c(3,4) # green solid and blue dashed lines
# combine all parameters
# lines 1,2,3, all red, and using line widths 2 to 4
lty= c(1,2,3)
col= 2
lwd= c(2:4)
# the most common situation for controlling the line type is adding
# the trend line to a scatter plot. For example:
plot(mtcars$gear)
abline(v = c(10,20), col = c(5,2), lty= c(2,2), lwd= c(2,3))
#1. Create an empty file in your working directory with your
# specified parameters
png("Figure1.png", width = 100, height = 100, units = 'mm', res = 300)
#2. Create your plot
with(PlantGrowth,hist(weight,
xlim= c(3,7), # set the x-axis range
ylim= c(0,10), # set the y-axis range
col= "beige", # fill the columns
border= "black", # column border
main= "Histogram of Plant Weights", # figure title
xlab= "Dried weight (g)", # x-axis label
ylab= "Frequency")) # y-axis label