Define options for an axis on a dygraph plot. Note that options will use the
default global setting (as determined by dyOptions
) when not
specified explicitly.
dyAxis(dygraph, name, label = NULL, valueRange = NULL, logscale = NULL,
ticker = NULL, rangePad = NULL, labelWidth = NULL, labelHeight = NULL,
axisHeight = NULL, axisLineColor = NULL, axisLineWidth = NULL,
pixelsPerLabel = NULL, axisLabelColor = NULL, axisLabelFontSize = NULL,
axisLabelWidth = NULL, axisLabelFormatter = NULL, valueFormatter = NULL,
drawGrid = NULL, gridLineColor = NULL, gridLineWidth = NULL,
independentTicks = NULL)
Dygraph to add an axis definition to
Axis name ('x', 'y', or 'y2')
Label to display for axis (defaults to none).
Explicitly set the vertical range of the graph to
c(low, high)
. This may be set on a per-axis basis to define each
y-axis separately. If either limit is unspecified, it will be calculated
automatically (e.g. c(NULL, 30)
to automatically calculate just the
lower bound).
When set for the y-axis or x-axis, the graph shows that axis in log scale. Any values less than or equal to zero are not displayed. Showing log scale with ranges that go below zero will result in an unviewable graph. Not compatible with showZero. connectSeparatedPoints is ignored. This is ignored for date-based x-axes.
This lets you specify an arbitrary JavaScript function to generate tick marks on an axis. The tick marks are an array of (value, label) pairs. The built-in functions go to great lengths to choose good tick marks so, if you set this option, you'll most likely want to call one of them and modify the result. See dygraph-tickers.js and the dygraphs documentation for additional details).
Add the specified amount of extra space (in pixels) around the value range to ensure points at the edges remain visible.
Width of the div which contains the y-axis label. Since the y-axis label appears rotated 90 degrees, this actually affects the height of its div.
Height of the x-axis label, in pixels. This also controls the default font size of the x-axis label. If you style the label on your own, this controls how much space is set aside below the chart for the x-axis label's div.
Height, in pixels, of the x-axis. If not set explicitly,
this is computed based on axisLabelFontSize
and axisTickSize
.
Color of the x- and y-axis lines. Accepts any value which the HTML canvas strokeStyle attribute understands, e.g. 'black' or 'rgb(0, 100, 255)'.
Thickness (in pixels) of the x- and y-axis lines.
Number of pixels to require between each x- and y-label. Larger values will yield a sparser axis with fewer ticks. Defaults to 50 (x-axis) or 30 (y-axes).
Color for x- and y-axis labels. This is a CSS color
string. This may also be set globally using dyOptions
.
Size of the font (in pixels) to use in the axis
labels, both x- and y-axis. This may also be set globally using
dyOptions
.
Width, in pixels, of the axis labels
JavaScript function to call to format the tick values that appear along an axis (see the dygraphs documentation for additional details).
JavaScript function to call to provide a custom display format for the values displayed on mouseover (see the dygraphs documentation for additional details).
Whether to display grid lines in the chart.
The color of the grid lines.
Thickness (in pixels) of the grid lines drawn under the chart.
Only valid for y and y2, has no effect on x: This option defines whether the y axes should align their ticks or if they should be independent. Possible combinations: 1.) y=true, y2=false (default): y is the primary axis and the y2 ticks are aligned to the the ones of y. (only 1 grid) 2.) y=false, y2=true: y2 is the primary axis and the y ticks are aligned to the the ones of y2. (only 1 grid) 3.) y=true, y2=true: Both axis are independent and have their own ticks. (2 grids) 4.) y=false, y2=false: Invalid configuration causes an error.
Axis options
# NOT RUN {
library(dygraphs)
dygraph(nhtemp, main = "New Haven Temperatures") %>%
dyAxis("y", label = "Temp (F)", valueRange = c(40, 60)) %>%
dyOptions(axisLineWidth = 1.5, fillGraph = TRUE, drawGrid = FALSE)
# }
Run the code above in your browser using DataLab