R Programming Seminar
Topic: Plot Customization, Plotting Regions and Margins
1. Introduction
R provides powerful tools for data visualization. Base R graphics allow customization of colors,
shapes, lines, text, margins, and plotting regions.
2. Plot Customization in R
2.1 Customizing Points
- pch: point shape (0–25)
- col: point color
- cex: point size
2.2 Customizing Lines
- lty: line type (1–6)
- lwd: line width
2.3 Titles and Labels
- main: main title
- xlab, ylab: axis labels
- sub: subtitle
2.4 Colors
- Named colors (e.g., "red")
- Hex codes
- Palettes: rainbow(), [Link](), [Link]()
3. Plotting Regions
3.1 Multiple Plots
Use par(mfrow=c(r,c)) to arrange plots in a grid.
3.2 [Link]()
Enables flexible division of the plotting window.
4. Margins in R
- mar: margins around individual plots
- oma: outer margins for multi-plot layouts
5. Axes Customization
- axes=FALSE removes default axes
- axis() adds custom axes
6. Adding Text, Lines, and Legends
- text(): add text inside plot
- abline(): add reference lines
- legend(): add legend
7. Saving Plots
Use png() or pdf() to save plots.
8. Summary
Plot customization includes control over points, lines, labels, margins, plotting regions, axes,
legends, and saving outputs.