Based Plot: Curve Plot

Published

November 5, 2024

Modified

September 24, 2025

Full Screen

Quick Reference: R Curve Plotting & Colors

Command Purpose
curve(expr, from, to, add, col, lwd, lty, main, xlab, ylab, bty) Plot mathematical functions; customize color, line width, type, and axis labels
plot(x, y, main, xlab, ylab) Create a base plot (scatter, line, etc.)
curve(expr, add=TRUE, …) Add a curve to an existing plot
legend(position, legend, col, lty) Add a legend to a plot
points(x, y, pch, col) Add points to a plot
text(x, y, labels, pos) Add annotations to a plot
library(RColorBrewer) Load RColorBrewer package
display.brewer.all() Display all available palettes
display.brewer.pal(n, "PaletteName") Display a specific palette with n colors
brewer.pal(n, "PaletteName") Extract vector of n colors
colorRampPalette(colors)(n) Create continuous gradient of n colors
barplot(values, col=my_palette, main="...") Barplot with custom colors
col2rgb(color) Convert color name/hex to RGB
rgb(r, g, b, alpha, maxColorValue=255) Generate color with transparency
make_transparent(color, alpha) Custom function to add transparency
pch Point shape (e.g., 16 = solid circle)
lwd Line width
lty Line type (0=blank, 1=solid, 2=dashed, 3=dotted, etc.)
bty="n" Remove plot box