Takes a data.frame and creates a lollipopplot
create.lollipopplot(
formula,
data,
filename = NULL,
groups = NULL,
main = NULL,
main.just = 'center',
main.x = 0.5,
main.y = 0.5,
main.cex = 3,
xlab.label = tail(sub('~', '', formula[-2]), 1),
ylab.label = tail(sub('~', '', formula[-3]), 1),
xlab.cex = 2,
ylab.cex = 2,
xlab.col = 'black',
ylab.col = 'black',
xlab.top.label = NULL,
xlab.top.cex = 2,
xlab.top.col = 'black',
xlab.top.just = 'center',
xlab.top.x = 0.5,
xlab.top.y = 0,
xlimits = NULL,
ylimits = NULL,
xat = TRUE,
yat = TRUE,
xaxis.lab = NA,
yaxis.lab = NA,
xaxis.log = FALSE,
yaxis.log = FALSE,
xaxis.cex = 1.5,
yaxis.cex = 1.5,
xaxis.rot = 0,
yaxis.rot = 0,
xaxis.fontface = 'bold',
yaxis.fontface = 'bold',
xaxis.col = 'black',
yaxis.col = 'black',
xaxis.tck = c(1,1),
yaxis.tck = c(1,1),
add.grid = FALSE,
xgrid.at = xat,
ygrid.at = yat,
grid.colour = NULL,
horizontal = FALSE,
type = 'p',
cex = 0.75,
pch = 19,
col = 'black',
col.border = 'black',
lwd = 1,
lty = 1,
alpha = 1,
axes.lwd = 1,
strip.col = 'white',
strip.cex = 1,
strip.fontface = 'bold',
y.error.up = NULL,
y.error.down = y.error.up,
x.error.right = NULL,
x.error.left = x.error.right,
y.error.bar.col = 'black',
x.error.bar.col = y.error.bar.col,
error.whisker.angle = 90,
error.bar.lwd = 1,
error.bar.length = 0.1,
key = list(text = list(lab = c(''))),
legend = NULL,
top.padding = 0.1,
bottom.padding = 0.7,
right.padding = 0.1,
left.padding = 0.5,
key.top = 0.1,
key.left.padding = 0,
ylab.axis.padding = 1,
axis.key.padding = 1,
layout = NULL,
as.table = FALSE,
x.spacing = 0,
y.spacing = 0,
x.relation = 'same',
y.relation = 'same',
add.axes = FALSE,
axes.lty = 'dashed',
add.xyline = FALSE,
xyline.col = 'black',
xyline.lwd = 1,
xyline.lty = 1,
abline.h = NULL,
abline.v = NULL,
abline.col = 'black',
abline.lwd = 1,
abline.lty = 1,
add.curves = FALSE,
curves.exprs = NULL,
curves.from = min(data, na.rm = TRUE),
curves.to = max(data, na.rm = TRUE),
curves.col = 'black',
curves.lwd = 2,
curves.lty = 1,
add.rectangle = FALSE,
xleft.rectangle = NULL,
ybottom.rectangle = NULL,
xright.rectangle = NULL,
ytop.rectangle = NULL,
col.rectangle = 'transparent',
alpha.rectangle = 1,
add.points = FALSE,
points.x = NULL,
points.y = NULL,
points.pch = 19,
points.col = 'black',
points.col.border = 'black',
points.cex = 1,
add.line.segments = FALSE,
line.start = NULL,
line.end = NULL,
line.col = 'black',
line.lwd = 1,
add.text = FALSE,
text.labels = NULL,
text.x = NULL,
text.y = NULL,
text.col = 'black',
text.cex = 1,
text.fontface = 'bold',
text.guess.labels = FALSE,
text.guess.skip.labels = TRUE,
text.guess.ignore.radius = FALSE,
text.guess.ignore.rectangle = FALSE,
text.guess.radius.factor = 1,
text.guess.buffer.factor = 1,
text.guess.label.position = NULL,
height = 6,
width = 6,
size.units = 'in',
resolution = 1600,
enable.warnings = FALSE,
description = 'Created with BoutrosLab.plotting.general',
style = 'BoutrosLab',
preload.default = 'custom',
group.specific.colouring = TRUE,
use.legacy.settings = FALSE,
inside.legend.auto = FALSE,
regions.labels = c(),
regions.start = c(),
regions.stop = c(),
regions.color = c("red"),
regions.cex = 1,
regions.alpha = 1,
lollipop.bar.y = NULL,
lollipop.bar.color = "gray",
...
);
The formula used to extract the x & y components from the data-frame
The data-frame to plot
Filename for tiff output, or if NULL returns the trellis object itself
The grouping variable in the data-frame
The main title for the plot (space is reclaimed if NULL)
The justification of the main title for the plot, default is centered
The x location of the main title, deault is 0.5
The y location of the main title, default is 0.5
Size of text for main plot title
x-axis label
y-axis label
Size of x-axis label, defaults to 3
Size of y-axis label, defaults to 3
Colour of the x-axis label, defaults to “black”
Colour of the y-axis label, defaults to “black”
The label for the top x-axis
Size of top x-axis label
Colour of the top x-axis label
Justification of the top x-axis label, defaults to centered
The x location of the top x-axis label
The y location of the top y-axis label
Two-element vector giving the x-axis limits, defaults to automatic
Two-element vector giving the y-axis limits, defaults to automatic
Vector listing where the x-axis labels should be drawn, defaults to automatic
Vector listing where the y-axis labels should be drawn, defaults to automatic
Vector listing x-axis tick labels, defaults to automatic
Vector listing y-axis tick labels, defaults to automatic
Logical indicating whether x-variable should be in logarithmic scale (and what base if numeric)
Logical indicating whether y-variable should be in logarithmic scale (and what base if numeric)
Size of x-axis scales, defaults to 2
Size of y-axis scales, defaults to 2
Counterclockwise rotation of text in x-axis scales in degrees, defaults to 0
Counterclockwise rotation of text in y-axis scales in degrees, defaults to 0
Fontface for the x-axis scales
Fontface for the y-axis scales
Colour of the x-axis tick labels, defaults to “black”
Colour of the y-axis tick labels, defaults to “black”
Specifies the length of the tick mark, defaults to 1 for both top and bottom axes
Specifies the length of the tick mark, defaults to 1 for both top and bottom axes
Logical stating wheter or not the grid should be drawn on the plot
Vector listing where the x-axis grid lines should be drawn, defaults to xat
Vector listing where the y-axis grid lines should be drawn, defaults to yat
ability to set individual grid line colours
xyplot-specific function that allows you to change if type='h' draws lines to the vertical or horizontal axis
Plot type
Character expansion for plotting symbol
Plotting character
Point/line colour
Colour of border when points pch >= 21. Defaults to “black”
Specifies line width, defaults to 1
Specifies line style, defaults to 1 (solid)
Specifies line transparency, defaults to 1 (opaque)
Thickness of width of axes lines
Strip background colour, defaults to “white”
Strip title character expansion
Strip title fontface, defaults to bold
upward error vector. Defaults to NULL. When y.error.up is NULL, vertical error bar is not drawn
Downward error vector. Defaults to y.error.down to show symmetric error bars
Rightward error vector. Defaults to NULL. When x.error.right is NULL, horizontal error bar is not drawn
Leftward error vector. Defaults to x.error.right to show symmetric error bars
Colour of vertical error bar. Defaults to “black”
Colour of horizontal error bar. Defaults to “black”
Angle of the whisker drawn on error bar. Defaults to 90 degree
Error bar line width. Defaults to 1
Length of the error bar whiskers. Defaults to 0.1
A list giving the key (legend). The default suppresses drawing
Add a legend to the plot. Helpful for adding multiple keys and adding keys to the margins of the plot. See xyplot.
A number specifying the distance to the top margin, defaults to 0.1
A number specifying the distance to the bottom margin, defaults to 0.7
A number specifying the distance to the right margin, defaults to 0.1
A number specifying the distance to the left margin, defaults to 0.5
A number specifying the distance at top of key, defaults to 0.1
Amount of padding to go onto any legend on the left
A number specifying the distance of ylabel to the y-axis, defaults to 1
A number specifying the distance from the y-axis to the key, defaults to 1
A vector specifying the number of columns, rows (e.g., c(2,1). Default is NULL; see lattice::xyplot for more details
Specifies panel drawing order, default is FALSE which draws panels from bottom left corner, moving right then up. Set to TRUE to draw from top left corner, moving right then down
A number specifying the distance between panels along the x-axis, defaults to 0
A number specifying the distance between panels along the y-axis, defaults to 0
Allows x-axis scales to vary if set to “free”, defaults to “same”
Allows y-axis scales to vary if set to “free”, defaults to “same”
Allow axis lines to be turned on or off, default is FALSE
Specifies axis line style, defaults to “dashed”
Allow y=x line to be drawn, default is FALSE
y=x line colour, defaults to black
Specifies y=x line width, defaults to 1
Specifies y=x line style, defaults to 1 (solid)
Allow horizontal line to be drawn, default to NULL
Allow vertical line to be drawn, default to NULL
Horizontal line colour, defaults to black
Specifies horizontal line width, defaults to 1
Specifies horizontal line style, defaults to 1 (solid)
Allow curves to drawn, default is FALSE
A list of functions, expressions, or calls using “x” as a variable that specify the curves to be drawn
Specifies the x co-ordinates at which the start of each curve should be drawn, defaults to drawing the curves to the left edge of the plotting region
Specifies the x co-ordinates at which the end of each curve should be drawn, defaults to drawing the curves to the right edge of the plotting region
Specifies colours of curves, default is black for each curve
Specifies width of curves, default is 1 for each curve
Specifies type of curves, default is 1 (solid) for each curve
Allow a rectangle to be drawn, default is FALSE
Specifies the left x ooordinate of the rectangle to be drawn
Specifies the bottom y coordinate of the rectangle to be drawn
Specifies the right x coordinate of the rectangle to be drawn
Specifies the top y coordinate of the rectangle to be drawn
Specifies the colour to fill rectangle's area
Specifies the colour bias of the rectangle to be drawn
Allow additional points to be drawn, default is FALSE
The x co-ordinates where additional points should be drawn
The y co-ordinates where additional points should be drawn
The plotting character for additional points
The colour of additional points
Colour of the border of additional points if points.pch >= 21. Defaults to black
The size of additional points
Allow additional line segments to be drawn, default is FALSE
The y co-ordinates where additional line segments should start
The y co-ordinates where additional line segments should end
The colour of additional line segments, default is black
The line width of additional line segments, default is 1
Allow additional text to be drawn, default is FALSE
Labels for additional text
The x co-ordinates where additional text should be placed
The y co-ordinates where additional text should be placed
The colour of additional text
The size of additional text
The fontface for additional text
Allows automatic labeling by considering values in text.x and text.y as a data point to be labelled, default is FALSE
Provides an option to disregard automatic labelling algorithm if no space is available around a data point, thus forcing labelling if a collision is likely, default is TRUE
Allows the automatic labeling algorithm to ignore the radius space of a data point, useful to label a cluster of data points with a single text box, default is FALSE
Allows the atuomatic labeling algorithm to ignore the rectangle space of multiple potential label positions, default is FALSE
A numeric value to factor the radius value to alter distance from the label and the data point
A numeric value to factor the buffer value to alter the space which is used to consider if data.points are potentially going to collide
A numeric value between 0 and 360 to specify the percise angle of a text box center and the positive x-axis. Angles move counter-clockwise beginning at the positive x axis
Figure height, defaults to 6 inches
Figure width, defaults to 6 inches
Figure units, defaults to inches
Figure resolution in dpi, defaults to 1600
Print warnings if set to TRUE, defaults to FALSE
Short description of image/plot; default NULL
defaults to “BoutrosLab”, also accepts “Nature”, which changes parameters according to Nature formatting requirements
ability to set multiple sets of diffrent defaults depending on publication needs
Variable to specify if group specific multi colouring for error bars is enforced
boolean to set wheter or not to use legacy mode settings (font)
boolean specifying whether or not to use the automatic inside legend function
Labels for each of the regions on the lollipop plots bars
start x value of each of the regions
stop value for each of the regions
color of each of the regions
size of the text of each of the regions
alpha of each of the regions
y location of top of the lollipop plot bar -- defaults to right above the bottom y axis
color of the lollipop plot bar
Additional arguments to be passed to xyplot
If filename
is NULL
then returns the trellis object, otherwise creates a plot and returns a 0/1 success code.
If this function is called without capturing the return value, or specifying a filename, it may crash while trying to draw the histogram. In particular, if a script that uses such a call of create histogram is called by reading the script in from the command line, it will fail badly, with an error message about unavailable fonts:
Error in grid.Call.graphics("L_text", as.graphicsAnnot(x$label), x$x, ) Invalid font type Calls: print ... drawDetails.text -> grid.Call.graphics -> .Call.graphics
xyplot
, lattice
or the Lattice book for an overview of the package.
# NOT RUN {
set.seed(12345);
lollipop.data <- data.frame(
y = seq(1,100,1),
x = rnorm(100)
);
create.lollipopplot(
filename = paste0(tempdir(),"/Lollipop_Simple.tiff"),
formula = x ~ y,
data = lollipop.data,
main = 'Lollipop plot',
xaxis.cex = 1,
xlimits = c(-1,102),
yaxis.cex = 1,
xaxis.fontface = 1,
yaxis.fontface = 1,
xlab.cex = 1.5,
ylab.cex = 1.5,
pch = 21,
col = 'black',
fill = 'transparent',
description = 'Scatter plot created by BoutrosLab.plotting.general',
regions.start = c(1,26,48),
regions.stop = c(15,35,72),
regions.labels = c("test 1", "test2", "test 3"),
regions.color = c("#66b3ff", "#5cd65c", "#ff3333")
);
# }
Run the code above in your browser using DataLab