lc_scatter {rlc} | R Documentation |
Visualize a set of points
Description
These functions plot a set of points with known coordinates that can be either categorical, or continuous.
Usage
lc_scatter(
data = list(),
place = NULL,
...,
chartId = NULL,
layerId = NULL,
with = NULL,
addLayer = FALSE,
pacerStep = 50
)
lc_beeswarm(
data = list(),
place = NULL,
...,
chartId = NULL,
layerId = NULL,
with = NULL,
addLayer = FALSE,
pacerStep = 50
)
Arguments
data |
Name-value pairs of properties passed through the |
place |
An ID of the container, where to place new chart. It will be ignored if the chart already exists. If not defined, the chart will be appended to the web page's body. |
... |
Name-value pairs of properties that will be evaluated only once and then will remain
constant. These properties can still be changed later using the |
chartId |
An ID for the chart. All charts must have unique IDs. If a chart with the same ID already
exists, it will be replaced unless |
layerId |
An ID for the new layer. All layers within one chart must have different IDs. If a layer with the same
ID already exists, it will be replaced. If not defined, it will be set to |
with |
A dataset or a list from which other properties should be taken. If the dataset doesn't have a
column with the requested name, the variable will be searched for outside of the dataset. Must be
a |
addLayer |
If there is already a chart with the same ID, this argument defines whether to replace it or to add a
new layer to it. This argument is ignored if both |
pacerStep |
Time in ms between two consecutive calls of an |
Functions
-
lc_scatter()
: creates a scatterplot and adds it as a new layer to an existing chart or creates a new one. -
lc_beeswarm()
: creates a special kind of scatterplot, where the points are spread along one of the axes to avoid overlapping.
Available properties
You can read more about different properties here.
-
x, y
- vector of x and y coordinates of the points. -
size
- sizes of the points. Default size is 6. -
opacity
- a vector of opacity values for each point in the range from 0 to 1. -
label
- vector of text labels for each point (labels by default are shown, when mouse hovers over a point). -
valueAxis
- (forlc_beeswarm
only) defines axis with values that will not be changed. Must be"x"
or"y"
(default). -
informText
- text that appears when the mouse cursor moves over an element. Unlikelabel
, completely overwrites the tooltip content with a custom HTML code. Must be a vector of characters (HTML code for each element).
Colour and shape settings
-
colour
- colour of the points. Must be a colour name or a hexadecimal code. -
colourValue
- grouping values for different colours. Can be numbers or characters. -
colourDomain
- a vector of all possible values for discrete colour scales or a range of all possible colour values for the continuous ones. -
palette
- a vector of colours to construct the colour scale. -
colourLegendTitle
- a title for the colour legend. -
addColourScaleToLegend
- whether or not to show the colour legend for the current layer. -
globalColourScale
- whether or not to use one colour scale for all the layers. -
symbol
- shape of each point. Must be one of"Circle"
,"Cross"
,"Diamond"
,"Square"
,"Star"
,"Triangle"
,"Wye"
. -
symbolValue
- grouping values for different symbols. -
symbolLegendTitle
- a title for the symbol value. -
stroke
- stroke colour for each element. Must be a colour name or a hexadecimal code. -
strokeWidth
- width of the strokes for each point.
Axes settings
-
logScaleX, logScaleY
- a base of logarithm for logarithmic scale transformation. If 0 orFALSE
no transformation will be performed. -
jitterX, jitterY
- amount of random variation to be added to the position of the points along one of the axes. 0 means no variation. 1 stands for distance betweenx
andx + 1
for linear scale,x
andb*x
for logarithmic scale (b
is a base of the logarithm), or between neighbouring ticks for categorical scale. -
shiftX, shiftY
- shift for each point from its original position along one of the axes. 0 means no shift. 1 stands for distance betweenx
andx + 1
for linear scale,x
andb*x
for logarithmic scale (b
is a base of the logarithm), or between neighbouring ticks for categorical scale. -
layerDomainX, layerDomainY
- default axes ranges for the given layer. -
domainX, domainY
- default axes ranges for the entire chart. If not defined, it is automatically set to include all layer domains. -
contScaleX, contScaleY
- whether or not the axis should be continuous. -
aspectRatio
- an aspect ratio for the chart. -
axisTitleX, axisTitleY
- axis titles. -
axisTitlePosX, axisTitlePosY
- positions of the axis titles. For each axis, one can specify a title position across or along the corresponding axis. Possible options are"up"
(for title inside the plotting area) or"down"
(outside the plotting area, under the axis), and"start"
,"middle"
,"end"
. This property must be a string with one or two of the aforementioned options (e.g."middle down"
,"start"
, etc.). -
ticksRotateX, ticksRotateY
- angles by which to rotate ticks (in degrees). Must be between 0 (horizontal ticks, default) and 90 (vertical ticks). -
ticksX, ticksY
- sets of ticks for the axes.
Interactivity settings
-
on_click
- a function, to be called when one of the points is clicked. Gets an index of the clicked point as an argument. -
on_clickPosition
- a function, to be called when any point of the chart is clicked. Unlikeon_click
, which is called only when an element of the chart (point, line, etc.) is clicked, this function reacts to any click on the chart. As an argument, it receives a vector of x and y coordinates of the click (based on the current axes scales). If one of the axes is categorical, the function will get the closest tick to the clicked position. -
on_mouseover
- a function, to be called when the mouse hovers over one of the points. Gets an index of the clicked point as an argument. -
on_mouseout
- a function, to be called when the mouse moves out of one of the points. -
on_marked
- a function, to be called when any of the points are selected (marked) or deselected. UsegetMarked
function to get the IDs of the currently marked points. To mark points, select them with your mouse while holding the Shift key.
Legend settings
-
legend_width
- width of the legend in pixels. The default value is 200. -
legend_height
- height of the legend in pixels. By default, it is equal to the height of the chart. -
legend_sampleHeight
- height of a single key of the legend in pixels. The default value is 20. -
legend_ncol
- number of columns to order several legends. By default, this is defined from the number of legends to reach close to a square shape. -
legend_container
- a DOM element of the web page where to place the legend. By default, the legend is positioned to the right from the chart in a table cell specifically made for it. This should be a valid CSS selector. If the specified element does not exist, the legend will be added to the web page's body.
Global chart settings
-
width
- width of the chart in pixels. -
heigth
- height of the chart in pixels. -
plotWidth
- width of the plotting area in pixels. -
plotHeight
- height of the plotting area in pixels. -
paddings
- padding sizes in pixels. Must be a list with all the following fields:"top", "bottom", "left", "right"
. -
title
- a title of the chart. -
titleX, titleY
- coordinates of the chart title. -
titleSize
- font-size of the chart title. -
showLegend
- whether or not to show the legend. -
showPanel
- whether of not to show the instrument panel (grey triangle in the upper-left corner of the chart). -
transitionDuration
- duration of the transitions between any two states of the chart. If 0, no animated transition is shown. It can be useful to turn the transition off, when lots of frequent changes happen to the chart.
Examples
## Not run: data("iris")
lc_scatter(dat(x = Sepal.Length,
y = Petal.Length,
colourValue = Petal.Width,
symbolValue = Species),
with = iris,
title = "Iris dataset",
axisTitleY = "Petal Length",
axisTitleX = "Sepal Length",
colourLegendTitle = "Petal Width",
symbolLegendTitle = "Species")
lc_beeswarm(dat(x = iris$Species,
y = iris$Sepal.Length,
colourValue = iris$Sepal.Width),
title = "Iris dataset",
axisTitleY = "Sepal Length",
axisTitleX = "Species",
colourLegendTitle = "Sepal Width")
## End(Not run)