amPlot: Plot serial data

View source: R/chart_amPlot.R

amPlotR Documentation

Plot serial data

Description

amPlot computes a plot of the given data values (can be a vector, dataframe or formula).

Usage

amPlot(x, ...)

## Default S3 method:
amPlot(x, ...)

## S3 method for class 'numeric'
amPlot(
  x,
  y,
  bullet = c("round", "diamond", "square", "bubble", "yError", "xError",
    "triangleLeft", "triangleRight", "triangleUp", "triangleDown"),
  type = c("points", "line", "smoothedLine", "step", "both"),
  col = "#0066cc",
  fill_alphas = 0,
  weights = NULL,
  precision = 2,
  title = NULL,
  id,
  error,
  xlab,
  ylab,
  lty,
  cex,
  lwd,
  xlim,
  ylim,
  ...
)

## S3 method for class 'character'
amPlot(
  x,
  y,
  bullet = c("round", "diamond", "square", "bubble", "yError", "xError",
    "triangleLeft", "triangleRight", "triangleUp", "triangleDown"),
  type = c("points", "line", "smoothedLine", "step", "both"),
  col = "#0066cc",
  fill_alphas = 0,
  weights = NULL,
  precision = 2,
  parseDates = FALSE,
  title = NULL,
  dataDateFormat,
  id,
  error,
  xlab,
  ylab,
  lty,
  cex,
  lwd,
  xlim,
  ylim,
  ...
)

## S3 method for class 'factor'
amPlot(
  x,
  y,
  bullet = "round",
  type = "p",
  col = "gray",
  weights = NULL,
  precision = 2,
  parseDates = FALSE,
  dataDateFormat = NULL,
  id,
  error,
  xlab,
  ylab,
  lty,
  cex,
  lwd,
  xlim,
  ylim,
  ...
)

## S3 method for class 'data.frame'
amPlot(x, columns, type = "l", precision = 2, xlab, ylab, fill_alphas = 0, ...)

## S3 method for class 'formula'
amPlot(x, data, type = "p", fill_alphas = 0, xlab, ylab, main = "", ...)

Arguments

x

the coordinates of points in the plot : numeric, data.frame, or formula.

...

see amOptions for more options.

y

numeric, the y coordinates of points in the plot, optional if x is an appropriate structure.

bullet

character, point shape. Possible values are : "diamond", "square", "bubble", "yError", "xError", "round", "triangleLeft", "triangleRight", "triangleUp", "triangleDown". Default set to "round".

type

character, type of plot. Possible values are : "l" for a line, "sl" for a smoothed line, "st" for step, "p" for points, and "b" for line and points. Default set to "p".

col

either a factor or a character, default set to "gray".

fill_alphas

a numeric between 0 and 1 for printed area.

weights

numeric, weights for x/y charts only. Small values are prefered for lisibility.

precision

numeric, precision you wish to display. Default set to 2.

title

character, name of the new serie, used when legend is enabled.

id

numeric, point id, for x/y charts only. Default 1:length(x).

error

numeric, only when type is "xError" "yError" default NULL,

xlab

character, label for x-axis.

ylab

character, label for y-axis.

lty

numeric, line type (dashes).

cex

numeric, bullet size.

lwd

numeric, line width

xlim

numeric, x range.

ylim

numeric, y range.

parseDates

logical, default set to FALSE, if TRUE argument dataDateFormat has to be provided.

dataDateFormat

character, default set to NULL. Even if your chart parses dates, you can pass them as strings in your dataframe - all you need to do is to set data date format and the chart will parse dates to date objects. Check this page for available formats. Please note that two-digit years (YY) as well as literal month names (MMM) are NOT supported in this setting.

columns

(optional) either a vector of character containing the names of the series to draw, or a numeric vector of indices. By default all numeric columns will be drawn.

data

dataset

main

title

Value

Return an Amchart.

References

See online documentation https://datastorm-open.github.io/introduction_ramcharts/ and amChartsAPI

See Also

amOptions, amBarplot, amBoxplot, amHist, amPie, amPlot, amTimeSeries, amStockMultiSet, amBullet, amRadar, amWind, amFunnel, amAngularGauge, amSolidGauge, amMekko, amCandlestick, amFloatingBar, amOHLC, amWaterfall

Examples


## Not run: 
# 'numeric':
amPlot(x = rnorm(100))

# add line
chart <- amPlot(x = rnorm(100), type = 'sl', legend = T)
amLines(chart, x = rnorm(100), type = "p")
    
# 'character':
start <- as.POSIXct('2015-01-01')
end <- as.POSIXct('2015-12-31')
date <- seq.POSIXt(from = start, to = end, by = 'day')
date <- format(date)

y <- rnorm(length(date))
amPlot(x = date, y = y, type = 'l', parseDates = TRUE, dataDateFormat = "YYYY-DD-MM")
# notice that by default 'parseDates = FALSE'

# 'data.frame'
amPlot(iris, col = colnames(iris)[1:2], type = c("l", "st"), zoom = TRUE, legend = TRUE)

# 'formula':
amPlot(Petal.Length + Sepal.Length ~ Sepal.Width, data = iris, legend = TRUE, zoom = TRUE)

## End(Not run)

## Not run: 
# Other examples available which can be time consuming depending on your configuration.
library(data.table)

iris <- as.data.table(get("iris", "package:datasets"))
x <- rnorm(100)

# Simple scatter plot with title and color
# Also change type (set to "p" by default), avalaible "l", "sl", "st", "p", "b"
amPlot(x = x, main = "Title", col = "lightblue", type = "b")

x <- sort(rnorm(100))
y <- runif(100)
weights <- runif(100, 0, 15)
amPlot(x = x, y = y, weights = weights)

## End(Not run)

rAmCharts documentation built on Sept. 30, 2022, 5:06 p.m.

Related to amPlot in rAmCharts...