Basic Plotting in R

Created by

Rischan Mafrur

Chonnam National University of South Korea

May 28, 2014

Actually in previous post we already know about how to plot the data into boxplot, histogram, pie chart, matrix scatter plot, so in this page i will show you about more plotting in R

First one is how to plot in 3D plot.

I still use Iris data, in this case i use scatterplot3d library, so you need to install first.


plot of chunk unnamed-chunk-1 Level plot, use library lattice

levelplot(Petal.Width~Sepal.Length*Sepal.Width, iris, cuts=9,

plot of chunk unnamed-chunk-2 with lattice package, we can use contour plot (use volcano dataset)

filled.contour(volcano, color=terrain.colors,asp=1,

plot of chunk unnamed-chunk-3

## $dim
## [1] 87 61
##  num [1:87, 1:61] 100 101 102 103 104 105 105 106 107 108 ...

Plotting numeric matrix 3D with persp

persp(volcano, theta=25, phi=30, expand=0.5, col="lightblue")

plot of chunk unnamed-chunk-6

Using ggplot, with ggplot we can visualize the data to beautiful plot.

p <- ggplot(iris, aes(Sepal.Length, Sepal.Width)) + geom_point(aes(color = Species,
shape = Species))
p + scale_colour_manual(values = c("red", "green", "blue"))

plot of chunk unnamed-chunk-7

p + scale_shape_manual(values = c(16, 17, 18))

plot of chunk unnamed-chunk-7

for more tutorial about ggplot visit => ,