iPlots is a package for the
statistical environment (see www.r-project.org)
which provides high interaction statistical graphics, written in Java.
It offers a wide variety of plots, including histograms, barcharts,
scatterplots, boxplots, fluctuation diagrams, parallel coordinates
plots and spineplots. All plots support interactive features, such
as querying, linked highlighting, color brushing, and interactive
changing of parameters. The iPlots package was introduced at
The various additions of Version 2.0 were introduced at the
userR!2006 Conference (http://www.r-project.org/useR-2006/).
Besides interactive plots,
iPlots also provides an API for managing plots
and adding user-defined objects, such as lines or polygons to a plot.
Version 2.0 not only adds
new multivariate plots and interactive features throughout all plots,
but also lays the foundations for interactive customizable plots (ICP).
(Right now, we mostly use the help-file examples - feel free to contribute!)
Mosaic plots in iPlots are fully interactive, i.e. they not only allow standard selection, highlighting and color brushing but also reordering of variables and the addition and exclusion of variables.
> library(MASS)Here is what you will get:
(to make the plot more interesting, we linked all cars with more
then 200 hp. The query provides exact information for the cell)
Besides the standard mosaic plot three further variations are implemented in iPlots:
To rearrange the variables use the four arrow keys ... you will soon get the idea of how to manage the variables!
Since most attempts to optimally place labels on mosaic plots fail sooner or later, we use a simple linear spacing for the first variables. Any further information should be queried using <ctrl>-mouse-over.
Barcharts in iPlots also feature Spineplots (use ctrl-s or the "View" menu to switch between the two representations)
To get a spineplot via the command line, there are two alternatives:
# directly upon creation
Bars can be reordered either by using the options in the "View" menu or by <alt>-dragging a bar to its desired position.
iPlots respect the order of a factor, so orderings from within R can be used to order the categories in a barchart.
Interactive maps - which use the data-format of the maptools package - will be availabe soon!
There is a whole family of parallel plots in iPlots.
I. Parallel Coordinate Plot
A parallel coordinate plot connects all cases by lines.
# Make a PCP for all continuous variables ...The default plot will scale all variables individually between min and max.
There are various options in the "View" menu including
II. Parallel Boxplot
Parallel boxplots are quite similar to PCPs but feature statistics like the median and the hinges, which makes them more useful for comparing distributions of variables.
# Make a parallel boxplot for all price variables ...
All options can be found in the "View" menu of the plot.
(Note, that the scale is only displayed when all variables share the same scale!)
III. Boxplot y by x
Boxplots y by x are quite different from the two other parallel plots, as they are conditional plots, showing boxplots by group. If ibox() is called with a continuous variable and a factor, a boxplot y by x is created
# split the boxplot for horsepower by number of cylinders
This example shows nicely that all cars having more than 200hp (this is the selected group) have either 6 or more cylinders or a rotary engine. Obviously, a boxplot y by x always uses the same scale for all boxplots for a proper comparison.
The scatterplot is probably the most frequently used plot of all statistical graphics. Scatterplots in iPlots can be used in the same way as the standard scatterplot in R.
> iplot(Horsepower, MPG.city)
Looking at the above example, a natural step would be to add a scatterplot smoother to the plot.
# create a default lowess smoother
We can also add some additional information to the plot:
# set point size to 5 and color the points by number of cylinders
Many other options for the scatterplot within iPlots can be found in the "View" menu.
Histograms in iPlots are fully interactive and can also be switched to the spineogram view.
Binwith and anchorpoint can either be changed interactively by <alt>-dragging the leftmost interval border (anchorpoint) or any other bin break (binwidth), or by explicitly specifying the two parameters via iplot.opt() or when creating the plot.
> iplot.opt(anchor=25, binw=25)
Histograms rescale by default when their parameters are changed, which can be controlled by two flags (see the help pages for details).
Selection in all iPlots can be done via selecting single objects like a point, a bar/rectangle or a line, or by creating a drag-box, which selects all points within the rectangle.
Via the iset-functions, the selection state of an iplot session can be queried and modified.
# get selected indices
All plots, which share the same iset are updated immediately.
To perform more complex selections, pressing the <shift>-modifier will select data in XOR mode.
Selections are a transient attribute of the data. Whenever a new selection is defined, the old selection state is overwritten. A persistent color attribute can be defined using color brushing within iPlots.
Color brushing can either be applied via the col=... option in iplot.opt() or any other iPlot graphics, or via the "View > Set Colors (CB)" menu command.
The same could be done from within R (though using the standard R colors) with:
# set colors according to Cylinders (using standard R colors)A second option for using color brushing is to apply rainbow colors over the range of a continuous variable. The menu command "View > Set Colors (rainbow)" will set the color scheme.
WIth iObjects you can annotate plots with further graphical elements. iObjects are
# create the scatterplot
Not really a good model, but at least we got rid of the outliers very easily.
There are some housekeeping functions for iObjects (please refer to the help files for details).
Interactive graphics benefits strongly from an interface which is highly consistent and has a flat learning curve. The most important functionality within iPlots are the keyboard shortcuts and modifier keys.
Many other common functions can be found in the "View" menu.
The handling of iPlots is done via a set of maintenance functions (see help files for details). The basic concept follows the handling of devices within R. It is, however, advisable to use plot objects directly, especially in scripts.
The α-channel can be used to specify the transparency of a painted object. This is useful, when plotting very many objects , which would otherwise result in heavy overplotting. Thus the density of objects can be easily displayed.
All glyph-based plots in iPlots offer α-channel transparency to handle large data and avoid
in parallel coordinate plots)
(α-transparency in a scatterplot - you recognise the dataset?!)
Use the arrow keys
(left and right) to interactively increase or decrease the transparency.
Where can I download iPlots?
Is there anything else I need to install in order to use iPlots?
iPlots needs SUN's JRE to run. For Windows and OS X it is recommended to use at least Sun Java 1.4 or higher.
For other UNIX operating systems (in particular Linux) Sun Java 1.5 or higher is highly recommended (64-bit Linux requires at least Java 1.6 beta). For the best user-experience, iPlots can be run from within JGR.
rJava fails to load on Unix, what can I do?
If you get a message similar to the following:Other Problems
Error in dyn.load(x, as.logical(local), as.logical(now)) :then your R was configured without Java support. To enable Java support in R, make sure you have installed R 2.4.0 or higher, Java works (e.g. java -version) and run as root:
R CMD javareconf
Please post questions and bug reports to the mailing list stats-rosuda-devel.
Issues of general interest will be posted on this page.
|Last update: Martin Theus, 04/29/2009|