R Graphics: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 11: | Line 11: | ||
* '''<code>barplot(x)</code>''' has many options | * '''<code>barplot(x)</code>''' has many options | ||
* '''<code>pie(x)</code>''' is pie chart | * '''<code>pie(x)</code>''' is pie chart | ||
* '''persp(x, y, z)''' plot a three-dimensional surface as viewed from a high point above | * '''<code>persp(x, y, z)</code>''' plot a three-dimensional surface as viewed from a high point above | ||
* '''<code>image(x, y, z)</code>''' plot a three-dimensional surface as viewed from directly above | * '''<code>image(x, y, z)</code>''' plot a three-dimensional surface as viewed from directly above | ||
* '''<code>contour(x,y,z)</code>''' like image, but contour map | * '''<code>contour(x,y,z)</code>''' like image, but contour map | ||
* '''<code>heatmap(x)</code>''' plot a single variable on two axes, each representing a different factor | * '''<code>heatmap(x)</code>''' plot a single variable on two axes, each representing a different factor | ||
* '''hist(x)''' histogram | * '''<code>hist(x)</code>''' histogram | ||
* '''<code>plot(density(x))</code>''' density plot is a continuous histogram | * '''<code>plot(density(x))</code>''' density plot is a continuous histogram | ||
Revision as of 16:03, 19 May 2011
Packages
graphics
package is first choice;
lattice
package is well suited for splitting data by a conditioning variable
Graphics package functions
Each function has dozens of options for customization
plot(x, y)
will plot vectors x and y as scatter plotmatplot(x, y)
plot corresponding points in an arbitrary pair of corresponding data objectssmoothscatter(x, y)
plots density of points for a very large number of pointsacf(ts)
autocorrelation function plot for time seriesbarplot(x)
has many optionspie(x)
is pie chartpersp(x, y, z)
plot a three-dimensional surface as viewed from a high point aboveimage(x, y, z)
plot a three-dimensional surface as viewed from directly abovecontour(x,y,z)
like image, but contour mapheatmap(x)
plot a single variable on two axes, each representing a different factorhist(x)
histogramplot(density(x))
density plot is a continuous histogram
Print graphics to a file
To print to a PNG file:
png("test.png") plot(density(lpt)) dev.off()
Options:
width (numeric), height (numeric), units ("in" for inches, etc), res (resolution as pixels per unit)
Other file types:
bmp, jpeg, tiff, postscript, pdf, pictex, xfig
.