Title: | Styling of Graphics using Cascading Style Sheets |
---|---|
Description: | Provides a means to style plots through cascading style sheets. This separates the aesthetics from the data crunching in plots and charts. |
Authors: | Tomasz Konopka [aut, cre] |
Maintainer: | Tomasz Konopka <[email protected]> |
License: | GPL-2 |
Version: | 1.1.0 |
Built: | 2024-11-10 11:11:37 UTC |
Source: | https://github.com/tkonopka/rcssplot |
This is a wrapper for R's abline function. See R's documentation for graphics::abline for further details.
abline( a = NULL, b = NULL, h = NULL, v = NULL, reg = NULL, coef = NULL, Rcss = "default", Rcssclass = NULL, ... )
abline( a = NULL, b = NULL, h = NULL, v = NULL, reg = NULL, coef = NULL, Rcss = "default", Rcssclass = NULL, ... )
a , b
|
coefficient (intercet and slope) for line |
h , v
|
horizontal, vertical positions for line |
reg |
an object with a coef method |
coef |
vector with interect and slope for line |
Rcss |
style sheet object. Leave "default" to use a style defined via RcssSetDefaultStyle(). |
Rcssclass |
character, style class |
... |
Further parameters, see documentation of abline() |
# draw a set of horizontal lines and a vertical line plot(c(0, 1), c(0, 1), type="n") abline(h=seq(0, 1, by=0.2)) abline(v=0.8)
# draw a set of horizontal lines and a vertical line plot(c(0, 1), c(0, 1), type="n") abline(h=seq(0, 1, by=0.2)) abline(v=0.8)
This is a wrapper for R's arrows function. See R's documentation for graphics::arrows for further details.
arrows(x0, y0, x1 = x0, y1 = y0, Rcss = "default", Rcssclass = NULL, ...)
arrows(x0, y0, x1 = x0, y1 = y0, Rcss = "default", Rcssclass = NULL, ...)
x0 , y0
|
coordinates of *from* endpoint |
x1 , y1
|
coordinates of *to* endpoint |
Rcss |
style sheet object. Leave "default" to use a style defined via RcssSetDefaultStle() |
Rcssclass |
character, style class |
... |
Futher parameters, see documentation of graphics::arrows |
# draw an arrow plot(c(0, 1), c(0, 1), type="n") arrows(0.2, 0.2, x1=0.8, y1=0.5)
# draw an arrow plot(c(0, 1), c(0, 1), type="n") arrows(0.2, 0.2, x1=0.8, y1=0.5)
This is a wrapper for R's axis function. See R's documentation for graphics::axis for further details.
axis(side, Rcss = "default", Rcssclass = NULL, ...)
axis(side, Rcss = "default", Rcssclass = NULL, ...)
side |
integer specifying what side of the plot to draw the axis. The codes are 1: bottom, 2: left, 3: top, 4: top. vertices |
Rcss |
style sheet object. Leave "default" to use a style defined via RcssSetDefaultStyle() |
Rcssclass |
sub class of style sheet |
... |
Further parameters, see documentation of graphics::axis |
# draw separate axes on an empty plot plot(c(0, 1), c(0, 1), type="n", axes=FALSE, xlab="x-axis", ylab="") axis(1) axis(3)
# draw separate axes on an empty plot plot(c(0, 1), c(0, 1), type="n", axes=FALSE, xlab="x-axis", ylab="") axis(1) axis(3)
This is a wrapper for R's barplot function. See R's documentation for graphics::barplot for further details.
barplot(height, Rcss = "default", Rcssclass = NULL, ...)
barplot(height, Rcss = "default", Rcssclass = NULL, ...)
height |
numeric vector giving bar lengths |
Rcss |
style sheet object. Leave "default" to use a style defined via RcssSetDefaultStyle() |
Rcssclass |
character, style class |
... |
Further parameters, see documentation of graphics::barplot |
# draw a complete barplot barplot(1:5)
# draw a complete barplot barplot(1:5)
This is a wrapper for R's box function. See R's documentation for graphics::box for further details.
box(which = "plot", Rcss = "default", Rcssclass = NULL, ...)
box(which = "plot", Rcss = "default", Rcssclass = NULL, ...)
which |
character specifying where to draw a box; see documentation of box() |
Rcss |
style sheet object. Leave "default" to use a style defined via RcssSetDefaultStyle() |
Rcssclass |
sub class of style sheet |
... |
Further parameters, see documentation of graphics::box |
# draw a box around an existing plot plot(c(0, 1), c(0, 1), type="n", frame=FALSE) box(lwd=3)
# draw a box around an existing plot plot(c(0, 1), c(0, 1), type="n", frame=FALSE) box(lwd=3)
This is a wrapper for R's boxplot function. See R's documentation for graphics::boxplot for further details.
boxplot(x, Rcss = "default", Rcssclass = NULL, ...)
boxplot(x, Rcss = "default", Rcssclass = NULL, ...)
x |
data for boxplot; either single numeric vector or a list of numeric vectors; see documentation of boxplot() |
Rcss |
style sheet object. Leave "default" to use a style defined via RcssSetDefaultStyle() |
Rcssclass |
character, style class |
... |
Further parameters, see documentation of graphics::boxplot |
# draw a complete boxplot dataset <- list(A=rpois(30, 10), B=rpois(30, 20)) boxplot(dataset, col=c("#dd0000", "#dd8888"))
# draw a complete boxplot dataset <- list(A=rpois(30, 10), B=rpois(30, 20)) boxplot(dataset, col=c("#dd0000", "#dd8888"))
This is a wrapper for R's cairo_pdf function. See R's documentation for grDevices::cairo_pdf for further details
cairo_pdf(filename, Rcss = "default", Rcssclass = NULL, ...)
cairo_pdf(filename, Rcss = "default", Rcssclass = NULL, ...)
filename |
character string with file name |
Rcss |
style sheet object. Leave "default" to use a style defined via RcssSetDefaultStyle() |
Rcssclass |
character, style class |
... |
Further parameters, see documentation of grDevices::pdf |
Note this uses styles from 'pdf' css selectors
# send content of graphics to a pdf file # to run this, un-comment the pdf() and dev.off() lines # cairo_pdf(file="example-file.pdf") barplot(1:5) # dev.off()
# send content of graphics to a pdf file # to run this, un-comment the pdf() and dev.off() lines # cairo_pdf(file="example-file.pdf") barplot(1:5) # dev.off()
This is a wrapper for R's contour function. See R's documentation for graphics::contour for further details.
contour( x = seq(0, 1, length.out = nrow(z)), y = seq(0, 1, length.out = ncol(z)), z, Rcss = "default", Rcssclass = NULL, ... )
contour( x = seq(0, 1, length.out = nrow(z)), y = seq(0, 1, length.out = ncol(z)), z, Rcss = "default", Rcssclass = NULL, ... )
x |
numeric vector; locations of grid lines |
y |
numeric vector; locations of grid lines |
z |
matrix of values |
Rcss |
style sheet object. Leave "default" to use a style defined via RcssSetDefaultStyle() |
Rcssclass |
character, style class |
... |
Further parameters, see documentation of graphics::contour |
# draw a complete contour plot dataset <- outer(1:10, 1:10) contour(z=dataset)
# draw a complete contour plot dataset <- outer(1:10, 1:10) contour(z=dataset)
This can be suitable for placing a label in a multi-panel figure. Note the automatic placement does not work when a plot is generated with logarithmic scales.
ctext( label, x = NULL, y = NULL, adj = NULL, cex = NULL, Rcss = "default", Rcssclass = NULL, ... )
ctext( label, x = NULL, y = NULL, adj = NULL, cex = NULL, Rcss = "default", Rcssclass = NULL, ... )
label |
character, text for corner label |
x , y
|
numeric, positions for manual placement |
adj |
numeric of length 2, argument adj for text |
cex |
numeric, argument cex for text |
Rcss |
style sheet object |
Rcssclass |
character, style class |
... |
additional argument, passed to text() |
plot(1:10, 1:10) ctext("A")
plot(1:10, 1:10) ctext("A")
This is a wrapper for R's grid function. See R's documentation for graphics::grid for further details.
grid(Rcss = "default", Rcssclass = NULL, ...)
grid(Rcss = "default", Rcssclass = NULL, ...)
Rcss |
style sheet object. Leave "default" to use a style defined via RcssSetDefaultStyle() |
Rcssclass |
character, style class |
... |
Further parameters, see documentation of graphics::grid |
# add a grid to an existing plot plot(c(0, 10), c(0, 10), type="n", xaxs="i", yaxs="i", las=1) grid(nx=10, ny=5, col="#777777")
# add a grid to an existing plot plot(c(0, 10), c(0, 10), type="n", xaxs="i", yaxs="i", las=1) grid(nx=10, ny=5, col="#777777")
This is a wrapper for R's hist function. See R's documentation for graphics::hist for further details.
hist(x, Rcss = "default", Rcssclass = NULL, ...)
hist(x, Rcss = "default", Rcssclass = NULL, ...)
x |
numeric vector |
Rcss |
style sheet object. Leave "default" to use a style defined via RcssSetDefaultStyle() |
Rcssclass |
character, style class |
... |
Further parameters, see documentation of graphics::hist |
# draw a complete histogram dataset <- rpois(400, 6) hist(dataset, breaks=seq(0, max(dataset))) # only obtain the bin counts, without plotting histdata <- hist(dataset, breaks=seq(0, 2+max(dataset), by=2), plot=FALSE) histdata
# draw a complete histogram dataset <- rpois(400, 6) hist(dataset, breaks=seq(0, max(dataset))) # only obtain the bin counts, without plotting histdata <- hist(dataset, breaks=seq(0, 2+max(dataset), by=2), plot=FALSE) histdata
This is a wrapper for R's jpeg function. See R's documentation for grDevices::jpeg for further details
jpeg(file, Rcss = "default", Rcssclass = NULL, ...)
jpeg(file, Rcss = "default", Rcssclass = NULL, ...)
file |
character string with file name |
Rcss |
style sheet object. Leave "default" to use a style defined via RcssSetDefaultStyle() |
Rcssclass |
character, style class |
... |
Further parameters, see documentation of grDevices::jpeg |
# send content of graphics to a jpg file # to run this, un-comment the jpeg() and dev.off() lines # jpeg(file="example-file.jpg") barplot(1:5) # dev.off()
# send content of graphics to a jpg file # to run this, un-comment the jpeg() and dev.off() lines # jpeg(file="example-file.jpg") barplot(1:5) # dev.off()
This is a wrapper for R's legend function. See R's documentation for graphics::legend for further details.
legend(x, y = NULL, legend, Rcss = "default", Rcssclass = NULL, ...)
legend(x, y = NULL, legend, Rcss = "default", Rcssclass = NULL, ...)
x , y
|
position of the legend |
legend |
character vector with labels (text appears in the legend) |
Rcss |
style sheet object. Leave "default" to use a style defined via RcssSetDefaultStyle() |
Rcssclass |
character, style class |
... |
Further parameters, see documentation of graphics::legend |
# add a legend to an existing plot plot(1:8, 1:8, col=rep(c(1,2), each=4), pch=19) legend(7, 3, c("A", "B"), pch=19, col=1:2)
# add a legend to an existing plot plot(1:8, 1:8, col=rep(c(1,2), each=4), pch=19) legend(7, 3, c("A", "B"), pch=19, col=1:2)
This is a wrapper for R's lines function. See R's documentation for graphics::lines for further details.
lines(x, y = NULL, Rcss = "default", Rcssclass = NULL, ...)
lines(x, y = NULL, Rcss = "default", Rcssclass = NULL, ...)
x , y
|
coordinates for start and end points for lines |
Rcss |
style sheet object. Leave "default" to use a style defined via RcssSetDefaultStyle() |
Rcssclass |
character, style class |
... |
Further parameters, see documentation of graphics::lines |
# add lines to an existing plot area plot(c(0, 10), c(0, 10), type="n") lines(c(1,8), c(2, 2), lwd=3, col="black") lines(c(1, 7, NA, 4, 9), c(1, 6, NA, 1, 3), lwd=1, col="blue") lines(c(8, 3), c(7, 9), lwd=3, lty=2, col="red")
# add lines to an existing plot area plot(c(0, 10), c(0, 10), type="n") lines(c(1,8), c(2, 2), lwd=3, col="black") lines(c(1, 7, NA, 4, 9), c(1, 6, NA, 1, 3), lwd=1, col="blue") lines(c(8, 3), c(7, 9), lwd=3, lty=2, col="red")
This is a wrapper for R's matplot function. See R's documentation for graphics::matplot for further details.
matplot(x, y, Rcss = "default", Rcssclass = NULL, ...)
matplot(x, y, Rcss = "default", Rcssclass = NULL, ...)
x , y
|
vectors or matrices of data for plotting. The number of rows should match. If one of them are missing, the other is taken as y and an x vector of 1:n is used. Missing values (NAs) are allowed. |
Rcss |
style sheet object. Leave "default" to use a style defined via RcssSetDefaultStyle() |
Rcssclass |
character, style class |
... |
Further parameters, see documentation of graphics::lines |
# draw scatter based on column in a matrix dataset = cbind(A=rnorm(20), B=rnorm(20)) matplot(dataset)
# draw scatter based on column in a matrix dataset = cbind(A=rnorm(20), B=rnorm(20)) matplot(dataset)
This is a wrapper for R's mtext function. See R's documentation for graphics::mtext for further details.
mtext(text, Rcss = "default", Rcssclass = NULL, ...)
mtext(text, Rcss = "default", Rcssclass = NULL, ...)
text |
characters to print on the plot |
Rcss |
style sheet object. Leave "default" to use a style defined via RcssSetDefaultStyle() |
Rcssclass |
character, style class |
... |
Further parameters, see documentation of graphics::mtext |
# draw text into a margin plot(c(0, 1), c(0, 1), type="n", xlab="", ylab="") mtext(side=1, "bottom x-axis label", line=2.5) mtext(side=2, "left y-axis label", line=2.5) mtext(side=3, "top x-axis label") mtext(side=4, "right y-axis label")
# draw text into a margin plot(c(0, 1), c(0, 1), type="n", xlab="", ylab="") mtext(side=1, "bottom x-axis label", line=2.5) mtext(side=2, "left y-axis label", line=2.5) mtext(side=3, "top x-axis label") mtext(side=4, "right y-axis label")
This is a wrapper for R's par function. See R's documentation for graphics::par for further details.
par(Rcss = "default", Rcssclass = NULL, ...)
par(Rcss = "default", Rcssclass = NULL, ...)
Rcss |
style sheet object. Leave "default" to use a style defined via RcssSetDefaultStyle() |
Rcssclass |
character, style class |
... |
Further parameters, see documentation of graphics::par |
# set properties for plot par(ps=8, mar=c(3, 8, 3, 1)) plot(c(0, 1), c(0, 1), type="n", frame=FALSE) text(rep(0.5, 2), c(0.2, 0.5), c("abc", "def")) par(ps=12) text(0.5, 0.8, "xyz")
# set properties for plot par(ps=8, mar=c(3, 8, 3, 1)) plot(c(0, 1), c(0, 1), type="n", frame=FALSE) text(rep(0.5, 2), c(0.2, 0.5), c("abc", "def")) par(ps=12) text(0.5, 0.8, "xyz")
The sequence of par() and plot() occurs so frequently that it a shortcut is helpful.
parplot(x, y, Rcss = "default", Rcssclass = NULL, ...)
parplot(x, y, Rcss = "default", Rcssclass = NULL, ...)
x , y
|
coordinates for points on the plot |
Rcss |
style sheet object, leave "default" to use a style defined via RcssDefaultStyle() |
Rcssclass |
character, style class |
... |
Further parameters, passed to plot() |
parplot(x=1:4, y=c(1,3,2,4))
parplot(x=1:4, y=c(1,3,2,4))
This is a wrapper for R's pdf function. See R's documentation for grDevices::pdf for further details
pdf(file, Rcss = "default", Rcssclass = NULL, ...)
pdf(file, Rcss = "default", Rcssclass = NULL, ...)
file |
character string with file name |
Rcss |
style sheet object. Leave "default" to use a style defined via RcssSetDefaultStyle() |
Rcssclass |
character, style class |
... |
Further parameters, see documentation of grDevices::pdf |
# send content of graphics to a pdf file # to run this, un-comment the pdf() and dev.off() lines # png(file="example-file.pdf") barplot(1:5) # dev.off()
# send content of graphics to a pdf file # to run this, un-comment the pdf() and dev.off() lines # png(file="example-file.pdf") barplot(1:5) # dev.off()
This is a wrapper for R's plot function. See R's documentation for graphics::plot for further details.
plot(x, y, Rcss = "default", Rcssclass = NULL, ...)
plot(x, y, Rcss = "default", Rcssclass = NULL, ...)
x , y
|
coordinates for points on the plot |
Rcss |
style sheet object. Leave "default" to use a style defined via RcssSetDefaultStyle() |
Rcssclass |
character, style class |
... |
Further parameters, see documentation of graphics::plot |
# draw a new empty plot area - unit square plot(c(0, 1), c(0, 1), type="n", xlab="", ylab="") # draw a plot area, automatically add some points plot(runif(20), rpois(20, 100))
# draw a new empty plot area - unit square plot(c(0, 1), c(0, 1), type="n", xlab="", ylab="") # draw a plot area, automatically add some points plot(runif(20), rpois(20, 100))
This is a wrapper for R's png function. See R's documentation for grDevices::png for further details.
png(file, Rcss = "default", Rcssclass = NULL, ...)
png(file, Rcss = "default", Rcssclass = NULL, ...)
file |
character string with file name |
Rcss |
style sheet object. Leave "default" to use a style defined via RcssSetDefaultStyle() |
Rcssclass |
character, style class |
... |
Further parameters, see documentation of grDevices::png |
# send content of graphics to a png file # to run this, un-comment the png() and dev.off() lines # png(file="example-file.png") barplot(1:5) # dev.off()
# send content of graphics to a png file # to run this, un-comment the png() and dev.off() lines # png(file="example-file.png") barplot(1:5) # dev.off()
This is a wrapper for R's points function. See R's documentation for graphics::points for further details.
points(x, y = NULL, Rcss = "default", Rcssclass = NULL, ...)
points(x, y = NULL, Rcss = "default", Rcssclass = NULL, ...)
x , y
|
coordinates for points on the plot |
Rcss |
style sheet object. Leave "default" to use a style defined via RcssSetDefaultStyle() |
Rcssclass |
character, style class |
... |
Further parameters, see documentation of graphics::points |
# draw a set of points onto an existing plot plot(c(0, 1), c(0, 1), type="n") points(runif(10), runif(10)) points(runif(10), runif(10), col="blue", pch=19)
# draw a set of points onto an existing plot plot(c(0, 1), c(0, 1), type="n") points(runif(10), runif(10)) points(runif(10), runif(10), col="blue", pch=19)
This is a wrapper for R's polygon function. See R's documentation for graphics::polygon for further details.
polygon(x, y = NULL, Rcss = "default", Rcssclass = NULL, ...)
polygon(x, y = NULL, Rcss = "default", Rcssclass = NULL, ...)
x , y
|
coordinates for polygon vertices |
Rcss |
style sheet object. Leave "default" to use a style defined via RcssSetDefaultStyle() |
Rcssclass |
character, style class |
... |
Further parameters, see documentation of graphics::polygon |
# draw a multi-sided shape on an existing plot plot(c(0, 10), c(0, 10), type="n", xlab="", ylab="") polygon(c(1, 4, 7, 7, 1), c(1, 1, 4, 8, 8), col="blue")
# draw a multi-sided shape on an existing plot plot(c(0, 10), c(0, 10), type="n", xlab="", ylab="") polygon(c(1, 4, 7, 7, 1), c(1, 1, 4, 8, 8), col="blue")
Display selectors encoded in an Rcss object. For more detailed information about the object, see function printRcss()
## S3 method for class 'Rcss' print(x, ...)
## S3 method for class 'Rcss' print(x, ...)
x |
style sheet object |
... |
Further parameters are ignored |
# define a custom style, display it custom.style <- Rcss(text="points { cex: 2; }") custom.style
# define a custom style, display it custom.style <- Rcss(text="points { cex: 2; }") custom.style
Display properties encoded in an Rcss object, including any subclasses.
printRcss(Rcss, selector = NULL, verbose = FALSE)
printRcss(Rcss, selector = NULL, verbose = FALSE)
Rcss |
style sheet object |
selector |
character string with name of selector to print |
verbose |
logical. If TRUE, function prints all information about the selector, including subclasses. If FALSE, function omits detailed information about subclasses. |
# define a custom style custom.style <- Rcss(text="points { pch:2; } points.A { pch: 3; }") # printing details for a selector, concise and verbose printRcss(custom.style, "points") printRcss(custom.style, "points", verbose=TRUE)
# define a custom style custom.style <- Rcss(text="points { pch:2; } points.A { pch: 3; }") # printing details for a selector, concise and verbose printRcss(custom.style, "points") printRcss(custom.style, "points", verbose=TRUE)
Creates a style sheet object using definition specified in an Rcss file. When a file is not specified, creates a base object object without any styling.
Rcss(file = NULL, text = NULL)
Rcss(file = NULL, text = NULL)
file |
filename containing Rcss definitions. If set to NULL, function returns a basic Rcss object. If multiple files, function reads each one and produces a joint style. |
text |
character, a string with Rcss |
See also related functions RcssGetDefaultStyle() and RcssOverload().
Rcss object
# define a custom style custom.style <- Rcss(text="plot { pch:19; col: 2 }") # display the custom style printRcss(custom.style, "plot") # use the custom style in a chart plot(1:4, 1:4, Rcss=custom.style)
# define a custom style custom.style <- Rcss(text="plot { pch:19; col: 2 }") # display the custom style printRcss(custom.style, "plot") # use the custom style in a chart plot(1:4, 1:4, Rcss=custom.style)
Creates a new Rcss style sheet object from the input, modifying one or more properties.
RcssChange( selector, propertylist = NULL, property = NULL, value = NULL, Rcssclass = NULL, Rcss = "default" )
RcssChange( selector, propertylist = NULL, property = NULL, value = NULL, Rcssclass = NULL, Rcss = "default" )
selector |
name of one selector ("text", "plot", "axis", etc.) |
propertylist |
list with property/value pairs to update |
property |
name of a single property. This is only used when propertylist is set to NULL |
value |
new values associated with property above. This is only used propertylist is set to NULL |
Rcssclass |
subclass of style sheet. Leave NULL to change base property. Provide one character value to edit one subclass. Provide a vector to edit a subclass of a subclass of a ... |
Rcss |
style sheet object |
always returns an Rcss object. Note: when changing the default style, this will return a new style without actually affecting the default style. To change how the default works in practice, assign this return value to RcssDefaultStyle
style1 <- Rcss(text="points { cex: 1; pch: 19; }") printRcss("points", Rcss=style1, verbose=TRUE) style2 <- RcssChange("points", list(cex=2), Rcss=style1) printRcss("points", Rcss=style2, verbose=TRUE)
style1 <- Rcss(text="points { cex: 1; pch: 19; }") printRcss("points", Rcss=style1, verbose=TRUE) style2 <- RcssChange("points", list(cex=2), Rcss=style1) printRcss("points", Rcss=style2, verbose=TRUE)
Creates a new Rcss style sheet object from the input, modifying one or more properties.
RcssChangePropertyValue( Rcss, selector, Rcssclass = NULL, propertylist = NULL, property = NULL, value = NULL )
RcssChangePropertyValue( Rcss, selector, Rcssclass = NULL, propertylist = NULL, property = NULL, value = NULL )
Rcss |
style sheet object |
selector |
name of one selector ("text", "plot", "axis", etc.) |
Rcssclass |
subclass of style sheet. Leave NULL to change base property. Provide one character value to edit one subclass. Provide a vector to edit a subclass of a subclass of a ... |
propertylist |
list with property/value pairs to update |
property |
name of a single property. This is only used when propertylist is set to NULL |
value |
new values associated with property above. This is only used propertylist is set to NULL |
Equivallent to RcssChange: use RcssChange instead
# use RcssChange instead
# use RcssChange instead
These style class (or classes) are applied in all functions of the Rcss family.
RcssCompulsoryClass
RcssCompulsoryClass
An object of class NULL
of length 0.
This style sheet will be applied in all functions of the Rcss family.
RcssDefaultStyle
RcssDefaultStyle
An object of class NULL
of length 0.
Fetches the value of the RcssCompulsoryClass object defined in parent environments.
RcssGetCompulsoryClass(Rcssclass = NULL)
RcssGetCompulsoryClass(Rcssclass = NULL)
Rcssclass |
character vector, set of additional compulsory classes. When NULL, function returns the current set of compulsory classes defined in parent environments. When non-NULL, functions returns the concatentation of the current set and new set. |
# retrieve the current compulsory class class.null <- RcssGetCompulsoryClass() # augment the current compulsory class with more labels class.A <- RcssGetCompulsoryClass("A") class.A class.B <- RcssGetCompulsoryClass("B") class.B # when the object RcssCompulsoryClass is set, this augments a vector RcssCompulsoryClass <- c("X", "Y") class.XYZ <- RcssGetCompulsoryClass("Z") class.XYZ
# retrieve the current compulsory class class.null <- RcssGetCompulsoryClass() # augment the current compulsory class with more labels class.A <- RcssGetCompulsoryClass("A") class.A class.B <- RcssGetCompulsoryClass("B") class.B # when the object RcssCompulsoryClass is set, this augments a vector RcssCompulsoryClass <- c("X", "Y") class.XYZ <- RcssGetCompulsoryClass("Z") class.XYZ
Fetches the value of the RcssDefaultStyle object defined in parent environments.
RcssGetDefaultStyle(Rcss = "default")
RcssGetDefaultStyle(Rcss = "default")
Rcss |
Rcss object, replacement default style object. When set to "default", the function returns a copy of the default object defined in parent environment. When set to Rcss object, the function ignores the default and returns the set object back. |
# retrieve the current default style style.now <- RcssGetDefaultStyle()
# retrieve the current default style style.now <- RcssGetDefaultStyle()
Extract a value for a property from an Rcss style sheet object. Returns a list with two items. "Defined" is a boolean that indicates the property is defined in the style sheet. "Value" gives the actual value of the property.
RcssGetPropertyValue(Rcss, selector, property, Rcssclass = NULL)
RcssGetPropertyValue(Rcss, selector, property, Rcssclass = NULL)
Rcss |
style sheet object |
selector |
name of selector of interest (e.g. "plot", "axis", "text", etc.) |
property |
name of property of interest (e.g. "col", "pch", etc.) |
Rcssclass |
subclass of style sheet |
Equivalent to RcssProperty; use RcssProperty instead.
# use RcssProperty or RcssValue instead
# use RcssProperty or RcssValue instead
If the requested property is defined within an Rcss object, this function will return the associated value. If the property is not defined, the function returns a default value that can be passed into the function and is set NULL otherwise. See also RcssGetPropertyValue().
RcssGetPropertyValueOrDefault( Rcss, selector, property, default = NULL, Rcssclass = NULL )
RcssGetPropertyValueOrDefault( Rcss, selector, property, default = NULL, Rcssclass = NULL )
Rcss |
style sheet object |
selector |
name of selector of interest (e.g. "plot", "axis", "text", etc.) |
property |
name of property of interest (e.g. "col", "pch", etc.) |
default |
value to return if the desired property is not defined in Rcss |
Rcssclass |
subclass of style sheet |
Equivalent to RcssValue(); use RcssValue() instead
# use RcssValue instead
# use RcssValue instead
Rcssplot graphics functions have 'Rcss' prefixes, e.g Rcsstext(). This function can be invoked to overload base-graphics functions by their Rcss wrappers. i.e. After executing this function, you can execute e.g. text() and automatically use the Rcss capabilities.
RcssOverload()
RcssOverload()
Warning: this function creates masking objects in your current environment for many base-graphics functions. See documentation for details.
# this function is deprecated - do not use it suppressWarnings(RcssOverload())
# this function is deprecated - do not use it suppressWarnings(RcssOverload())
Extract information about property and its value
RcssProperty(selector, property, Rcssclass = NULL, Rcss = "default")
RcssProperty(selector, property, Rcssclass = NULL, Rcss = "default")
selector |
character, name of selector, e.g. 'points' |
property |
character, name of property, e.g. 'col' |
Rcssclass |
character or vector, subclass in Rcss |
Rcss |
Rcss object |
list with two ites. Component "defined" is a boolean that indicates whether the property is defined in the style. Component "value" gives the actual value associated to the property.
style1 <- Rcss(text="points { cex: 2; }") # cex is defined, col is not defined RcssProperty("points", "cex", Rcss=style1) RcssProperty("points", "col", Rcss=style1)
style1 <- Rcss(text="points { cex: 2; }") # cex is defined, col is not defined RcssProperty("points", "cex", Rcss=style1) RcssProperty("points", "col", Rcss=style1)
If the selector and property are defined in the Rcss object, this function will return the value stored in the Rcss object. Otherwise, the function will return a default value. See also related functions RcssGetPropertyValueOrDefault, which is the same, except that RcssValue is shorter to write and takes the Rcss object as its last argument.
RcssValue( selector, property, default = NULL, Rcssclass = NULL, Rcss = "default" )
RcssValue( selector, property, default = NULL, Rcssclass = NULL, Rcss = "default" )
selector |
character, name of selector, e.g. 'points' |
property |
character, name of property to get, e.g. 'col' |
default |
value to return if selector/property are not defined |
Rcssclass |
character or vector, subclass in Rcss |
Rcss |
Rcss object |
a value from the Rcss object
style1 <- Rcss(text="custom { key: 100 }") RcssValue("custom", "key", default=1, Rcss=style1) RcssValue("custom", "key2", default=0, Rcss=style1)
style1 <- Rcss(text="custom { key: 100 }") RcssValue("custom", "key", default=1, Rcss=style1) RcssValue("custom", "key2", default=0, Rcss=style1)
This is a macro script that loads R code and a default Rcss style, and then executes a function. This process is repeated indefinitely.
RcssWatch(f, files = NULL, ...)
RcssWatch(f, files = NULL, ...)
f |
function or character of function name, executed at each iteration |
files |
character, paths to R and Rcss files |
... |
other arguments, passed to function f |
# Note: the examples below draw a charat once and exit. # To enable quick re-drawing, RcssWatch must be provided with file paths # draw and redraw a bar plot RcssWatch(plot, x=1:4, y=1:4) # alternative syntax, using a function name as a string custom.barplot <- function(x=1:4, main="") { barplot(x, main=main) } RcssWatch("custom.barplot", main="Custom") # for more interesting behavior, specify a files with styles and R source
# Note: the examples below draw a charat once and exit. # To enable quick re-drawing, RcssWatch must be provided with file paths # draw and redraw a bar plot RcssWatch(plot, x=1:4, y=1:4) # alternative syntax, using a function name as a string custom.barplot <- function(x=1:4, main="") { barplot(x, main=main) } RcssWatch("custom.barplot", main="Custom") # for more interesting behavior, specify a files with styles and R source
This is a wrapper for R's rect function. See R's documentation for graphics::rect for further details.
rect(xleft, ybottom, xright, ytop, Rcss = "default", Rcssclass = NULL, ...)
rect(xleft, ybottom, xright, ytop, Rcss = "default", Rcssclass = NULL, ...)
xleft , ybottom , xright , ytop
|
vector of coordinates for rectangles' vertices |
Rcss |
style sheet object. Leave "default" to use a style defined via RcssSetDefaultStyle() |
Rcssclass |
character, style class |
... |
Further parameters, see documentation of graphics::rect |
# draw rectangles on an existing plot plot(c(0, 10), c(0, 10), type="n", xlab="", ylab="") rect(4.5, 1, 5.5, 3) rect(c(1, 7.5), c(6, 6), c(2.5, 9), c(8, 8))
# draw rectangles on an existing plot plot(c(0, 10), c(0, 10), type="n", xlab="", ylab="") rect(4.5, 1, 5.5, 3) rect(c(1, 7.5), c(6, 6), c(2.5, 9), c(8, 8))
This is a wrapper for R's stripchart function. See R's documentation for graphics::stripchart for further details.
stripchart(x, Rcss = "default", Rcssclass = NULL, ...)
stripchart(x, Rcss = "default", Rcssclass = NULL, ...)
x |
list of numeric vectors |
Rcss |
style sheet object. Leave "default" to use a style defined via RcssSetDefaultStyle() |
Rcssclass |
character, style class |
... |
Further parameters, see documentation of graphics::stripchart |
# draw a complete strip-chart plot dataset <- list(A=c(1,9,3,8), B=c(3,4,2,9,2), C=rpois(8, 10)) stripchart(dataset) stripchart(dataset, method="jitter", vertical=TRUE, pch=19)
# draw a complete strip-chart plot dataset <- list(A=c(1,9,3,8), B=c(3,4,2,9,2), C=rpois(8, 10)) stripchart(dataset) stripchart(dataset, method="jitter", vertical=TRUE, pch=19)
This is a wrapper for R's svg function. See R's documentation for grDevices::svg for further details
svg(filename, Rcss = "default", Rcssclass = NULL, ...)
svg(filename, Rcss = "default", Rcssclass = NULL, ...)
filename |
character string with file name |
Rcss |
style sheet object. Leave "default" to use a style defined via RcssSetDefaultStyle() |
Rcssclass |
character, style class |
... |
Further parameters, see documentation of grDevices::svg |
# send content of graphics to a pdf file # to run this, un-comment the pdf() and dev.off() lines # svg(file="example-file.svg") barplot(1:5) # dev.off()
# send content of graphics to a pdf file # to run this, un-comment the pdf() and dev.off() lines # svg(file="example-file.svg") barplot(1:5) # dev.off()
This is a wrapper for R's text function. See R's documentation for graphics::text for further details.
text( x, y = NULL, labels = seq_along(x), Rcss = "default", Rcssclass = NULL, ... )
text( x, y = NULL, labels = seq_along(x), Rcss = "default", Rcssclass = NULL, ... )
x , y
|
coordinates where to write labels |
labels |
characters to print on the plot |
Rcss |
style sheet object. Leave "default" to use a style defined via RcssSetDefaultStyle() |
Rcssclass |
character, style class |
... |
Further parameters, see documentation of graphics::text |
# add text to an existing plot plot(c(0, 1), c(0, 1), type="n") text(0.1, 0.1, "A") text(c(0.2, 0.7), c(0.8, 0.6), c("B", "C"))
# add text to an existing plot plot(c(0, 1), c(0, 1), type="n") text(0.1, 0.1, "A") text(c(0.2, 0.7), c(0.8, 0.6), c("B", "C"))
This is a wrapper for R's title function. See R's documentation for graphics::title for further details.
title( main = NULL, sub = NULL, xlab = NULL, ylab = NULL, Rcss = "default", Rcssclass = NULL, ... )
title( main = NULL, sub = NULL, xlab = NULL, ylab = NULL, Rcss = "default", Rcssclass = NULL, ... )
main |
plot title |
sub |
plot sub title |
xlab , ylab
|
labels on axes |
Rcss |
style sheet object. Leave "default" to use a style defined via RcssSetDefaultStyle() |
Rcssclass |
character, style class |
... |
Further parameters, see documentation of graphics::title |
# add a title plot(c(0, 1), c(0, 1), type="n", xlab="", ylab="") title("This is the title") title(sub="This is a bottom title")
# add a title plot(c(0, 1), c(0, 1), type="n", xlab="", ylab="") title("This is the title") title(sub="This is a bottom title")