Title: | iPlots - Interactive Graphics for R |
---|---|
Description: | Interactive plots for R. |
Authors: | Simon Urbanek <[email protected]>, Tobias Wichtrey <[email protected]> |
Maintainer: | Simon Urbanek <[email protected]> |
License: | GPL-2 |
Version: | 1.1-8 |
Built: | 2024-11-27 06:55:29 UTC |
Source: | CRAN |
This function adds one straight line through the current iPlot.
iabline(a = NULL, b = NULL, reg = NULL, coef = NULL, ..., plot = iplot.cur())
iabline(a = NULL, b = NULL, reg = NULL, coef = NULL, ..., plot = iplot.cur())
a , b
|
the intercept and slope |
coef |
a vector of length two giving the intercept and slope |
reg |
an object with a |
... |
object options for |
plot |
plot to which this line is to be added |
Typical usages are
iabline(a, b, ...) iabline(coef=, ...) iabline(reg=, ...)
Resulting iObject.
This function creates a new interactive bar chart from the given data.
ibar(var, ...)
ibar(var, ...)
var |
Factor, vector of strings or variable to use. |
... |
All additional parameters are passed to
|
Creates an interactive barchart or spline plot.
Additional parameters (also accessible via iplot.opt
):
drawTicks
Whether ticks should be drawn.
isSpine
Whether a spineplot should be created instead of a normal barchart.
borderColorSel
Here this color defaults to black. See
iplot.opt
for details.
Resulting plot object.
iplot
, ihist
, iplot.list
,
iplot.opt
data(iris) attach(iris) ibar(Species)
data(iris) attach(iris) ibar(Species)
This function creates a new interactive box plot from the given data.
ibox(x, y=NULL, ...)
ibox(x, y=NULL, ...)
x |
Vector of numbers or data frame containing the variables |
y |
A factor to specify groups for y-by-x boxplot |
... |
All additional parameters are passed to
|
Creates either a regular boxplot (if y
is not specified) or
'x-by-y boxplot (if y
is specified). In the latter case both
x
and y
must be of the same length.
Additional parameters:
Whether lables should be placed alternately at the top and at the bottom.
Resulting plot object.
ihist
, ibar
, iplot.list
,
iplot.opt
data(iris) attach(iris) ibox(Petal.Length) ibox(Sepal.Length,Species)
data(iris) attach(iris) ibox(Petal.Length) ibox(Sepal.Length,Species)
This function provides a way of building interactive event loops in R. Currently SJava interface has no stable callbacks, therefore this is the only way of defining new interactions in iPlots.
ievent.wait
waits until some iPlots event (iEvent)
occurs. The most commonly used events include selection change and
the "break" event. It is possible to generate user-definable events
(such as events sent by custom buttons or menu entries) with low-level
API (via SJava)
Note that in the current implementation the Windows GUI "freezes" until the function returns.
ievent.wait()
ievent.wait()
NULL
is the break
event occured or a ievent
object if some other event occured.
data(iris) attach(iris) iplot(Sepal.Length, Petal.Length) d<-iplot.data() iabline(lm(d$y ~ d$x), col = "red") ilines(lowess(d$x,d$y), col = "#0000c0") ilines(c(0,0),c(0,0), col = "marked", visible = FALSE) cat("Select 'Break' from the menu of any plot to return back to R.\n") while (!is.null(ievent.wait())) { if (iset.sel.changed()) { s <- iset.selected() if (length(s) > 1) iobj.opt(x=lowess(d$x[s],d$y[s]),visible = TRUE) else iobj.opt(visible = FALSE) } } for(i in 1:3) iobj.rm() iplot.off()
data(iris) attach(iris) iplot(Sepal.Length, Petal.Length) d<-iplot.data() iabline(lm(d$y ~ d$x), col = "red") ilines(lowess(d$x,d$y), col = "#0000c0") ilines(c(0,0),c(0,0), col = "marked", visible = FALSE) cat("Select 'Break' from the menu of any plot to return back to R.\n") while (!is.null(ievent.wait())) { if (iset.sel.changed()) { s <- iset.selected() if (length(s) > 1) iobj.opt(x=lowess(d$x[s],d$y[s]),visible = TRUE) else iobj.opt(visible = FALSE) } } for(i in 1:3) iobj.rm() iplot.off()
This function creates a new interactive hammock plot. Please note that a hammock plot was not necessarily designed to support highlighting, so it may be of limited use. It was created as a proof of the iBase concept which makes it very easy to implement new interactive plots.
ihammock(...)
ihammock(...)
... |
All unnamed parameters are treated as variables to
display. All additional parameters are passed to |
The plot can be used in either in the form ihammock(df)
to plot
a list or data frame of variables or ihammock(x, y, z)
to plot
factors x
, y
and z
.
Resulting plot object.
library(MASS) data(Cars93) attach(Cars93) ihammock(AirBags, Cylinders, Origin)
library(MASS) data(Cars93) attach(Cars93) ihammock(AirBags, Cylinders, Origin)
This function creates a new interactive histogram from the given data.
ihist(var, ...)
ihist(var, ...)
var |
Vector of numbers or variable to use. |
... |
All additional parameters are passed to
|
Creates an interactive histogram.
Additional parameters (also available via iplot.opt
):
Anchor point for the histogram.
Bin width.
Whether the x axis should be automatically rescaled.
Whether the y axis should be automatically rescaled.
Resulting plot object.
iplot
, ibar
, iplot.list
,
iplot.opt
data(iris) ihist(iris$Sepal.Width)
data(iris) ihist(iris$Sepal.Width)
A generic function taking coordinates of points in data space and creating corresponding connected lines or polygon in the current iPlot.
ilines(x, y, col=NULL, fill=NULL, visible=NULL, plot = iplot.cur())
ilines(x, y, col=NULL, fill=NULL, visible=NULL, plot = iplot.cur())
x , y
|
Coordinate vectors of points to
join. |
col |
Drawing color of the lines. Currently only |
fill |
Color of the polygon area or |
visible |
If set to |
plot |
parent plot for the lines |
The point vectors x
and y
can contain NA
values,
in which case each sequence of points separated by NA
s will be
treated as a separate polygon. NA
s must be present in both
coordinates at the same index, otherwise the behavior is undefined.
Resulting iObject.
ihist
, ibar
, iplot.list
,
iobj.opt
data(iris) attach(iris) iplot(Sepal.Width,Petal.Width) l<-lowess(Sepal.Width,Petal.Width) ilines(l)
data(iris) attach(iris) iplot(Sepal.Width,Petal.Width) l<-lowess(Sepal.Width,Petal.Width) ilines(l)
This function creates a new interactive map from the given data.
imap(x, y=NULL, ...)
imap(x, y=NULL, ...)
x |
either an object of the class |
y |
y-coordinates of the map polygons |
... |
All additional parameters are passed to
|
Creates an interactive map plot.
The input can be either an object of the class "map"
passed
directly to the x
parameter or two vectors of matching
coordinates passed to x
and y
. The format for polygons
in the same as used by the map
function.
Each polygon should correspond to a case and it will be linked
correspondingly. See ivar.new.map
for details on map
variables.
Note: this function is currently experimental and it may change in the future.
Resulting plot object.
library(maps) m <- map('state', plot=FALSE) imap(m)
library(maps) m <- map('state', plot=FALSE) imap(m)
This function creates a new interactive mosaic plot from the given data.
imosaic(...)
imosaic(...)
... |
All unnamed parameters are treated as variables to
display. Additional parameters are passed to
|
The plot can be used either in the form imosaic(df)
to plot
a list or data frame of variables contained in df
or
imosaic(x, y, z)
to plot variables x
, y
and
z
.
Additional parameters:
The default value of this variable is changed
here. For a description see iplot.opt
.
Resulting plot object.
ihist
, ibar
, iplot.list
,
iplot.opt
library(MASS) data(Cars93) attach(Cars93) imosaic(AirBags,Cylinders,Origin) imosaic(AirBags,Cylinders,Origin,type="mul") iplot.location(300,100,TRUE)
library(MASS) data(Cars93) attach(Cars93) imosaic(AirBags,Cylinders,Origin) imosaic(AirBags,Cylinders,Origin,type="mul") iplot.location(300,100,TRUE)
These functions are used to manage iObjects of an iPlot. Exactly one of the iObjects is the current one (for each iPlot). Every newly created iObject automatically becomes current.
Please note that both iPlots and iObjects can be also used directly -
each function creating an iObject or iPlot returns the newly created
object which can be used in calls to functions requiring plot
parameter (for iPlots) or iobj.opt
, iobj.rm
and similar
(iObjects). The object list management functions below are provided
for convenience only - the direct use of objects is encouraged
instead.
iobj.list
returns all iObjects of the current iPlot.
iobj.cur
returns the current iObject.
iobj.next
and iobj.prev
return the ID
of the next resp. previous object in the list relative to the object
specified by the argument.
iobj.set
makes the object with the specified ID current.
iobj.get
returns the object specified by its ID.
iobj.rm
removes the object
==
and !=
operators can be used to compare two iObjects
iobj.list(plot = iplot.cur()) iobj.cur(plot = iplot.cur()) iobj.next(which=iobj.cur(), plot = iplot.cur()) iobj.prev(which=iobj.cur(), plot = iplot.cur()) iobj.set(which=iobj.next()) iobj.get(pos, plot=iplot.cur()) iobj.rm(which=iobj.cur(), plot = iplot.cur()) ## S3 method for class 'iobj' a == b ## S3 method for class 'iobj' a != b
iobj.list(plot = iplot.cur()) iobj.cur(plot = iplot.cur()) iobj.next(which=iobj.cur(), plot = iplot.cur()) iobj.prev(which=iobj.cur(), plot = iplot.cur()) iobj.set(which=iobj.next()) iobj.get(pos, plot=iplot.cur()) iobj.rm(which=iobj.cur(), plot = iplot.cur()) ## S3 method for class 'iobj' a == b ## S3 method for class 'iobj' a != b
which |
An object or an integer specifying the object number. |
pos |
ID of an object |
plot |
plot to operate on (either as integer ID or plot object itself). |
a |
object to compare |
b |
object to compare |
This function modifies parameters of an iObject.
iobj.opt(o=iobj.cur(),...)
iobj.opt(o=iobj.cur(),...)
o |
object whose options are to be set |
... |
options to be set |
If no parameters (except for the object) are specified, a list of the current parameters is returned (if supported by the object).
The following common parameters are used by most iObjects:
visible
visibility flag. The default is TRUE
.
layer
layer in which the object is placed. Currently the
following layers are supported: 0 - background, 1 - data points, 2 -
selection, 3 - drag boxes. The value -1 has a special meaning by
denoting the topmost layer (which is the default)
col
drawing color of the object
fill
filling color of the object (where applicable). If set to
NA
then no filling is performed.
coord
coordinates system to use. 0=graphical coordinates,
1=data space coordinates (default), 2=relative coordinates.
update
if set to FALSE
then no plot refresh is done
after updating the options. When modifying multiple objects it is
common practice to set update
to FALSE
for all but the last
updated object. The default is TRUE
.
This function creates a new interactive parallel coordinates plot from the given data.
ipcp(...)
ipcp(...)
... |
All unnamed parameters are treated as variables to
display. All additional parameters are passed to
|
Creates an interactive parallel coordinates plot.
The plot can be used either in the form ipcp(df)
to plot
a list or data frame of variables contained in df
or
ipcp(x, y, z)
to plot variables x
, y
and
z
.
Additional parameters:
alterningLabels
Whether lables should be placed alternately at the top and at the bottom.
COL_AXES
Color of the (optional) axes.
Resulting plot object.
ihist
, ibar
, iplot.list
,
iplot.opt
data(iris) ipcp(iris)
data(iris) ipcp(iris)
This function creates a new interactive scatterplot from the given data.
iplot(x, y=NULL, xlab=NULL, ylab=NULL, ...)
iplot(x, y=NULL, xlab=NULL, ylab=NULL, ...)
x |
Data for the x axis. It can be either a vector of values or a variable of an iset. If y is not given, this must be a list of one of these. |
y |
Data for the y axis. It can be either a vector of values or a variable of an iset. |
xlab |
Name for x variable. |
ylab |
Name for y variable. |
... |
All additional parameters are passed to
|
Creates an interactive scatterplot.
Additional parameters:
Number of pixels the point diameter should be changed when in-/decreasing it via keyboard or menu.
Whether to use a custom background color.
COL_CUSTOMBG
The custom background color.
Whether axes should be drawn.
Whether the same scale should be applied to both axes.
Minimal point diameter.
Point diameter.
Gives the amount of space around the data points. 1.0 means no space, 1.5 means half as much space around the data as is used for the data itself. This resets zoom.
Default values:
changePtDiamBy=2, customFieldBg=FALSE, COL_CUSTOMBG="white", drawAxes=TRUE, equiscale=FALSE, minimalDiam=1, ptDiam=3, spaceprop=1.1
Resulting plot object.
ihist
, ibar
, iplot.list
,
iplot.opt
data(iris) attach(iris) iplot(Sepal.Width,Petal.Width) iplot(Sepal.Width/Sepal.Length, Species)
data(iris) attach(iris) iplot(Sepal.Width,Petal.Width) iplot(Sepal.Width/Sepal.Length, Species)
This function retrieves the associated data from the current plot.
iplot.data(id=NULL)
iplot.data(id=NULL)
id |
number of the variable to retrieve. If omitted a list of all associated varaibles (and their contents) is returned. |
A vector representaing a variable or a list of variable contents. The
first two vecctors in the list are traditionally named x
and
y
. The number of variables depends on the plot used,
e.g. scatter plot has two, histogram or bar chart return one.
data(iris) attach(iris) iplot(Sepal.Width,Petal.Width) iplot(Sepal.Width/Sepal.Length, Species)
data(iris) attach(iris) iplot(Sepal.Width,Petal.Width) iplot(Sepal.Width/Sepal.Length, Species)
These functions are used to manage currently open iPlots. Exactly one
of the open iPlots is the current plot. Every newly created iPlot
automatically becomes the current plot. Any plot specific functions, such
as ilines
operate on the current plot.
Please note that the functions below are provided for convenience
only. It is also possible to use plot objects directly without using
the plot list. Each function creating a new iPlot directly returns
the plot object which can then be used to any subsequent calls to
ilines
, iplot.opt
etc.
iplot.list
returns all currently registered iPlots
(even if they are hidden).
iplot.cur
returns the ID of the current plot.
iplot.next
and iplot.prev
return the ID
of the next resp. previous plot in the list relative to the plot
specified by the argument.
iplot.set
makes the plot with the specified ID current.
iplot.off
closes the plot.
iplot.list() iplot.cur() iplot.next(which=iplot.cur()) iplot.prev(which=iplot.cur()) iplot.set(which=iplot.next()) iplot.off(plot=iplot.cur())
iplot.list() iplot.cur() iplot.next(which=iplot.cur()) iplot.prev(which=iplot.cur()) iplot.set(which=iplot.next()) iplot.off(plot=iplot.cur())
which |
An integer specifying a plot number. |
plot |
Plot object or plot number of a plot to close. |
data(iris) attach(iris) iplot(Sepal.Width,Petal.Width) ibar(Species) iplot.list()
data(iris) attach(iris) iplot(Sepal.Width,Petal.Width) ibar(Species) iplot.list()
The following functions are used to mainpulate iplots. They are NOT
part of the official API and may disappear without warning. Most of
them are legacy functions introduced before iplot.opt
was
available.
iplot.backend
retrieves or sets the iPlots back-end.
iplot.resetZoom
reset zoom
iplot.rotate
set plot rotation
iplot.setExtendedQuery
set text for extended query
iplot.zoomIn
zoom into specified area
iplot.zoomOut
zoom out (the coordinates are ignored as the zoom
is heararchical)
iplot.location
get or set the location of the iplot
iplot.size
get or set the size of an iplot plot
iplot.backend(type = NULL) iplot.resetZoom() iplot.rotate(i) iplot.setExtendedQuery(str, plotID=.iplot.curid) iplot.zoomIn(x1, y1, x2, y2) iplot.zoomOut(x, y) iplot.location(x, y, relative=FALSE, plot=iplot.cur()) iplot.size(width, height, plot=iplot.cur()) ## S3 method for class 'iobj' print(x, ...) ## S3 method for class 'iplot' print(x, ...)
iplot.backend(type = NULL) iplot.resetZoom() iplot.rotate(i) iplot.setExtendedQuery(str, plotID=.iplot.curid) iplot.zoomIn(x1, y1, x2, y2) iplot.zoomOut(x, y) iplot.location(x, y, relative=FALSE, plot=iplot.cur()) iplot.size(width, height, plot=iplot.cur()) ## S3 method for class 'iobj' print(x, ...) ## S3 method for class 'iplot' print(x, ...)
i |
rotation orientation |
plotID |
plot ID (number) |
str |
string to show on extended query or
|
type |
back-end type - one of |
x1 |
basis coordinate for the |
y1 |
basis coordinate for the |
x2 |
edge coordinate for the |
y2 |
edge coordinate for the |
x |
object to print or x-coordinate |
y |
y-coordinate |
plot |
plot to query or move (id or object) |
relative |
can be |
width |
width of the plot (in pixels) |
height |
height of the plot (in pixels) |
... |
additional parameters |
iplot.location
, iplot.size
: those functions either query
or set the location or size of the plot. If either of the coordinates
is missing, the size/location in that coordinate will not be changed.
If both coordinates are missing, the functions have no side effect and
just return the current size (iplot.size
) or location and size
(iplot.location
) as named vectors (x
, y
for
location and width
, height
for size).
iplot.backend
determines the back-end used by iplots. The
choices are awt
, swing
an dopengl
. Not all
back-ends are available on all platforms. AWT
is the most
compatible back-end and available on all platforms, Swing
has
more modern look and feel and OpenGL
sacrifices text rendering
quality for speed (i.e. OpenGL backend is best for large data). When
no backend is specified, the function has no side effect and just
returns the currently requested back-end. Currently there is no
indication whether the back-end request was honored or not. If a
backend is not supported, the request is silently ignored.
This function modifies parameters of an iPlot.
iplot.opt(..., plot=iplot.cur())
iplot.opt(..., plot=iplot.cur())
... |
Parameters to modify |
plot |
Plot whose parameters are to be modified |
The following parameters are common to all plots. See help pages of individual plots for plot-specific parameters.
xlim
Range of the X axis (vector of two numbers).
ylim
Range of the Y axis (vector of two numbers).
col
Colors of the points. See iset.brush
for
details.
autoAdjustMargins
Whether iPlots should try to determine appropriate margin sizes. Set this to FALSE if you want to set the margins manually.
defaultMargins
Vector of default values for left, right, top and bottom margins.
mLeft
Size of left margin.
mRight
Size of right margin.
mTop
Size of top margin.
mBottom
Size of bottom margin.
fillColor
Fill color.
borderColor
Border color.
fillColorSel
Fill color when selected.
borderColorSel
Border color when selected.
fillColorDrag
Fill color of dragged bars.
COL_INVALID
Color of invalid elements.
COL_OUTLINE
Default line color.
COL_SELBG
Background color of selection rectangle. Defaults to selection color with alpha value 0.298.
COL_ZOOMBG
Background color of selection rectangle.
horizontalMedDist
Mean horizontal label distance.
horizontalMinDist
Minimal horizontal label distance.
verticalMedDist
Mean vertical label distance.
verticalMinDist
Minimal vertical label distance.
extQueryString
Extended query string.
rotateYLabels
Whether labels for the y axis should be rotated by the angle given by rotateYLabelsBy.
rotateYLabelsBy
The labels for the y axis are rotated by this amount of degrees if rotateYLabels is set to true.
title
Frame title.
If no parameters (except for the plot) are specified, a list of the current parameters is returned.
data(iris) attach(iris) iplot(Sepal.Width,Petal.Width) iplot.opt(xlim=c(1.5,5),col=Species)
data(iris) attach(iris) iplot(Sepal.Width,Petal.Width) iplot.opt(xlim=c(1.5,5),col=Species)
iraster
adds a raster image as an iObj to the given iPlot.
Position in the plot is specified by bottom-left and top-right points
of the image.
iraster(x1, y1, x2, y2, img, ..., plot = iplot.cur())
iraster(x1, y1, x2, y2, img, ..., plot = iplot.cur())
x1 , y1 , x2 , y2
|
coordinates of the bottom-left (x1, y1) and
top-right (x2, y2) corner. Alternatively, |
img |
image to draw. It can be either a raster, file name, binary connection or a raw vector containing an image in a common image format such as PNG or JPEG. If it is a raster, then the raster is first encoded into PNG format and passed as raw vector. |
... |
additional arguments that will be passed to
|
plot |
parent plot for the image |
The current implementation uses Java's ImageIO API to read the
image, so the supported formats will depend on your Java
implemetation. Raster objects (i.e., of class "raster"
,
"nativeRaster"
), matrices and arrays) are simply passed to
png::writePNG(img)
so for anything other than computationally
constructed objects it is more efficient to use the encoded image.
Resulting iObject.
## very silly example ... iplot(0:20/20, 0:20/20) ## get a sample image (R logo) from the png package fn <- system.file("img", "Rlogo.png", package="png") ## put this image behind all points iraster(0, 0, 1, 1, fn, layer=-2) ## you can use a raster but it's less eficient ## this one goes to the top layer where iObjs reside normally iraster(0, 0, 0.5, 0.5, png::readPNG(fn))
## very silly example ... iplot(0:20/20, 0:20/20) ## get a sample image (R logo) from the png package fn <- system.file("img", "Rlogo.png", package="png") ## put this image behind all points iraster(0, 0, 1, 1, fn, layer=-2) ## you can use a raster but it's less eficient ## this one goes to the top layer where iObjs reside normally iraster(0, 0, 0.5, 0.5, png::readPNG(fn))
iPlots maintain a separate copy of all data that are displayed in the iPlots. This allows iPlots to opearate even after the underlying data has been deleted in R. It also allows iPlots to use hot linking in all aspects, including update of plots on data changes.
This data management consists mainly of two classes: iset
and
ivar
. The iset
object encapsuletes an iSets which
can be thought of as a kind of special data frame that allows linking
of all variables contained therein. Each variable (or column in
data.frame-speech) is represented by an ivar
object
encapsulating an iVar.
An instance of a ivar
class can be use to create new iplots or
update data in the existing iplots. Convenience operators on both
ivar
and iset
objects include those such as
length
, subsetting and subassignment and therefor from user's
point of view it is possible to use them transparently a data frames
(iSet) or vectors (iVar). In addition, iSet supports methods such as
names
or dim
.
iset
returns the object corresponding to a given iSet.
isets
returs objects for all iSets
iset(which=iset.cur()) isets() ## S3 method for class 'iset' x[[i]] ## S3 method for class 'iset' x$name ## S3 replacement method for class 'iset' x$name <- value ## S3 replacement method for class 'iset' x[[i]] <- value ## S3 method for class 'iset' x[i = 1:(dim(x)[1]), j = 1:length(x)] ## S3 replacement method for class 'iset' x[i = 1:(dim(x)[1]), j = 1:length(x)] <- value ## S3 replacement method for class 'iset' names(x) <- value ## S3 method for class 'iset' names(x) ## S3 method for class 'iset' length(x) ## S3 method for class 'iset' dim(x)
iset(which=iset.cur()) isets() ## S3 method for class 'iset' x[[i]] ## S3 method for class 'iset' x$name ## S3 replacement method for class 'iset' x$name <- value ## S3 replacement method for class 'iset' x[[i]] <- value ## S3 method for class 'iset' x[i = 1:(dim(x)[1]), j = 1:length(x)] ## S3 replacement method for class 'iset' x[i = 1:(dim(x)[1]), j = 1:length(x)] <- value ## S3 replacement method for class 'iset' names(x) <- value ## S3 method for class 'iset' names(x) ## S3 method for class 'iset' length(x) ## S3 method for class 'iset' dim(x)
x |
iset object |
i |
row (case) index |
j |
column (variable) index |
value |
replacement value |
which |
An integer specifying an iSet ID or a string specifying a name of the iSet. |
name |
name of the variable |
data(iris) s <- iset.new("iris", iris) rm(iris) s[] names(s) dim(s) length(s) s[[1]] s$Species s[1:5,c("Sepal.Length","Petal.Length")] rm(s) # even if we get rid of the reference object, # we can get it back s <- iset() s # see ?ivar for more examples
data(iris) s <- iset.new("iris", iris) rm(iris) s[] names(s) dim(s) length(s) s[[1]] s$Species s[1:5,c("Sepal.Length","Petal.Length")] rm(s) # even if we get rid of the reference object, # we can get it back s <- iset() s # see ?ivar for more examples
This function sets the colors of cases of an iSet. Every iPlot is free to use the corresponding representation individually. Color of a case is a iSet-global property, that is all iPlots associated with an iSet will reflect the change.
iset.col(col)
iset.col(col)
col |
Vector of integers specifying colors or a factor. The values are re-cycled if necessary. 0 has a special meaning denoting "no color", i.e. the plot is free to use the default color. This is also the default state of a newly created iSet. |
data(iris) attach(iris) iplot(Sepal.Width,Petal.Width) ibar(Species) iset.col(Species)
data(iris) attach(iris) iplot(Sepal.Width,Petal.Width) ibar(Species) iset.col(Species)
These functions are used to manage iSets. An iSets groups all iPlots which use the same data as a basis. All iPlots belonging to an iSet are linked, that is selecting cases in one iPlot cause the same cases to be highlighted in all other iPlots based on the same iSet. The linking is done on case-level, therefore the variables should have the same number of cases.
You can get the iset object by calling the iset
function. An
iset object can be used in a way similar to data frames, so subsetting
and other operations work as expected. Subassignment is always done
"live", so changeing parts of the data will cause plots to be updated
accordingly.
There is always exactly one current iSet. An initial iSet called "default" is created when the iplots library is loaded. All new iPlots are created using the current iSet. The set of functions described here allow the manipulation of iSets.
Note that changing the iSet also has an effect on
iplot.list
and iobj.list
since iPlots
are linked to their iSets.
iset.new
creates a new iSet and makes it current
iset.list
returns all iSets
iset.cur
returns the ID of the current iSet
iset.next
and iset.prev
return the ID
of the next resp. previous iSet in the list relative to the iSet
specified by the argument.
iset.set
makes the iSet with the specified ID current.
iset.rm
removes the given iSet and all associated plots.
Note that this may cause the current set ID may change (even if some
other iSet is removed).
print.iset
prints an iSet object.
iset.new(name=NULL, payload=NULL) iset.list() iset.cur() iset.next(which=iset.cur()) iset.prev(which=iset.cur()) iset.set(which=iset.next()) iset.rm(which=iset.cur()) ## S3 method for class 'iset' print(x, ...)
iset.new(name=NULL, payload=NULL) iset.list() iset.cur() iset.next(which=iset.cur()) iset.prev(which=iset.cur()) iset.set(which=iset.next()) iset.rm(which=iset.cur()) ## S3 method for class 'iset' print(x, ...)
name |
Name of the new iSet. If no name is specified, an automatic name of the form "data.X" is created where "X" is an integer. The name can be used instead on an ID in many cases. |
payload |
Initial contents of the iSet in the form of a
list/data.frame or |
which |
An integer specifying an iSet ID or a string specifying a name of the iSet. |
x |
An iSet object to print |
... |
further parameters to be passed to |
signature(object = "iset")
: is mapped to
print.iset
These functions modify the selection or return the currently selected (highlighted) cases.
iset.selected
returns a vector of IDs of all currently
selected cases (in the current iSet)
iset.select
changes the selection of the current
iSet. All plots are updated immediately to reflect the new selection.
iset.sel.changed
returns TRUE
if the selection
has changed since last call to this function.
iset.selectAll
selects everything
iset.selectNone
clears all selections (yes, not a good name)
iset.selected() iset.select(what, mode="replace", mark=TRUE, batch=FALSE) iset.sel.changed(iset=iset.cur()) iset.selectAll(batch=FALSE) iset.selectNone(batch=FALSE)
iset.selected() iset.select(what, mode="replace", mark=TRUE, batch=FALSE) iset.sel.changed(iset=iset.cur()) iset.selectAll(batch=FALSE) iset.selectNone(batch=FALSE)
what |
specification of the new selection. This can be either a vector of case IDs or a logical vector. |
mode |
mode to be used when combining the previous selection and teh surrent one. Supported modes are "replace", "union" and "intersect". |
mark |
mark to be used. |
iset |
iSet to query |
batch |
when set to |
List of IDs of selected cases (iset.selected
), boolean value
(iset.sel.changed
).
data(iris) attach(iris) iplot(Sepal.Length,Petal.Length) iset.select(Species=="virginica")
data(iris) attach(iris) iplot(Sepal.Length,Petal.Length) iset.select(Species=="virginica")
text
adds the strings given in the vector labels
at the
coordinates given by x
and y
to the current iPlot. y
may be missing since
xy.coords(x,y)
is used for construction of the coordinates.
itext(x, y=NULL, labels=seq(along=x), ax=NULL, ay=NULL, ..., plot = iplot.cur())
itext(x, y=NULL, labels=seq(along=x), ax=NULL, ay=NULL, ..., plot = iplot.cur())
x , y
|
Coordinate vectors of the text. |
labels |
one or more character strings or expressions specifying the text to be written. |
ax , ay
|
anchor coordinates of the text. They specify where is the
point specified by |
... |
any additional options are passed to |
plot |
parent plot |
Resulting iObject.
The following functions are used to mainpulate variables for iplots:
ivar.data
returns the data associated with an iVar
variable
ivar.new
creates a new iVar
variable in the current
iSet
using the supplied data
ivar.new.map
same as ivar.new
but for map (polygon) data
ivar.update
replaces the content of a variable
iVar
variables (deprecated - use iset.new
instead)
[.ivar
allows data subsetting of ivar contents
[<-.ivar
allows partial replacement of ivar contents
length.ivar
returns the length of a variable
iset.updateVars
notifies all plots that variables have been
changed. This function should not be normally used, because
notification happens automatically, unless batch updates are
performed.
ivar.data(var) ivar.new(name = deparse(substitute(cont)), cont) ivar.new.map(name, x, y) ivar.update(var, cont, batch = FALSE) ## S3 method for class 'ivar' length(x) ## S3 method for class 'ivar' x[i, ...] ## S3 replacement method for class 'ivar' x[...] <- value ## S3 method for class 'ivar' print(x, ...) iset.updateVars()
ivar.data(var) ivar.new(name = deparse(substitute(cont)), cont) ivar.new.map(name, x, y) ivar.update(var, cont, batch = FALSE) ## S3 method for class 'ivar' length(x) ## S3 method for class 'ivar' x[i, ...] ## S3 replacement method for class 'ivar' x[...] <- value ## S3 method for class 'ivar' print(x, ...) iset.updateVars()
var |
an existing |
cont |
desired contents - usually a numeric vector or a factor |
name |
variable name in an iSet |
batch |
if set to |
x |
object to subset or x-coordinate of the map data |
y |
y-coordinate of the map data |
i |
index - if missing all data are returned |
... |
indices |
value |
replacement value |
All data that will are displayed in an iPlot are organized in
iSet
s. Each iSet
contains variables, called
iVar
s, that represent the displayed data. Typically an
iSet
corresponds to a data frame and an iVar
corresponds
to a column in a data frame. All variables in one iSet
must
have the same length and indexing order. This allows iPlots to perform
proper linking of all plots.
Before some data can be displayed in an iPlot, they are put into an
ivar
using the ivar.new
function. Each variable has a
name that is unique within an iSet
. This process is automatic
if you pass arbitrary vectors to the iPlots plotting
functions. However, it is possible (and desirable) to register
variables beforehand using iset.new
. It is much faster
to use iVar
s in the plots instead of the raw data.
Once an iVar
is created, it is merely a reference to the data
in the iSet
. The regular subsetting operators [
or
ivar.data
function can be used to retrieve the data back to R.
In addition, it is possible to update the contents of an iVar
using the ivar.update
function. Once the variable is updated,
all plots that use the variable will be updated, too, and reflect the
change, unless batch
was set to TRUE
. The notification
is performed using the iset.updateVars
function.
signature(object = "ivar")
: is mapped to
print.ivar
iset.new
, ibar
, iplot.list
,
iplot.opt
data(iris) s <- iset.new("iris", iris) rm(iris) # we don't need iris anymore s[1:5,] s$Species s$Species[] s[1:5,c("Sepal.Width","Sepal.Length")] s$Test <- factor(c("yes","no")[runif(dim(s)[1])+1.5]) s[1:5,] iplot(s$Sepal.Length, s$Petal.Length) ibar(s$Species) iplot.location(400,,TRUE) iset.select(s$Test[]=="yes") ibar(s$Test) iplot.location(400,250,TRUE) # use iset.rm() to remove everything
data(iris) s <- iset.new("iris", iris) rm(iris) # we don't need iris anymore s[1:5,] s$Species s$Species[] s[1:5,c("Sepal.Width","Sepal.Length")] s$Test <- factor(c("yes","no")[runif(dim(s)[1])+1.5]) s[1:5,] iplot(s$Sepal.Length, s$Petal.Length) ibar(s$Species) iplot.location(400,,TRUE) iset.select(s$Test[]=="yes") ibar(s$Test) iplot.location(400,250,TRUE) # use iset.rm() to remove everything