amBarplot {rAmCharts} | R Documentation |
Plotting bar chart using rAmCharts
Description
amBarplot computes a bar chart of the given values.
Usage
amBarplot(
x,
y,
data,
xlab = "",
ylab = "",
ylim = NULL,
groups_color = NULL,
horiz = FALSE,
stack_type = c("none", "regular", "100"),
layered = FALSE,
show_values = FALSE,
depth = 0,
dataDateFormat = NULL,
minPeriod = ifelse(!is.null(dataDateFormat), "DD", ""),
...
)
Arguments
x |
|
y |
|
data |
|
xlab |
|
ylab |
|
ylim |
limits for the y axis. |
groups_color |
|
horiz |
|
stack_type |
|
layered |
|
show_values |
|
depth |
|
dataDateFormat |
|
minPeriod |
Specifies the shortest period of your data. This should be set only if dataDateFormat is not 'NULL'. Possible period values: fff - milliseconds, ss - seconds, mm - minutes, hh - hours, DD - days, MM - months, YYYY - years. It's also possible to supply a number for increments, i.e. '15mm' which will instruct the chart that your data is supplied in 15 minute increments. |
... |
see amOptions for more options. |
Details
Notice about labels: if the chart has many columns, several labels might be hidden. It depends on the width of the conatainer where the chart is displayed. Zoom on the chart to see if the chart can contain all labels. If not, use the parameter labelRotation. You can also add a cursor to your chart...
Value
An object of class 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:
# Data
data(data_bar)
data(data_gbar)
amBarplot(x = "country", y = "visits", data = data_bar, main = "example")
# Other examples available which can be time consuming depending on your configuration.
# fixed value axis
amBarplot(x = "year", y = c("income", "expenses"), data = data_gbar, ylim = c(0, 26))
amBarplot(x = "year", y = c("income", "expenses"), data = data_gbar, stack_type = "100")
# Test with label rotation
amBarplot(x = "country", y = "visits", data = data_bar, labelRotation = -45)
# Horizontal bar
amBarplot(x = "country", y = "visits", data = data_bar, horiz = TRUE, labelRotation = -45)
# 3D bar
amBarplot(x = "country", y = "visits", data = data_bar, depth = 15, labelRotation = -45)
# Display values
amBarplot(x = "country", y = "visits", data = data_bar, show_values = TRUE, labelRotation = -45)
# Grouped columns
amBarplot(x = "year", y = c("income", "expenses"), data = data_gbar)
# Parse dates
# Default label: first day of each year
amBarplot(x = "year", y = c("income", "expenses"), data = data_gbar,
dataDateFormat = "YYYY", minPeriod = "YYYY")
# Default label: first day of each month
amBarplot(x = "month", y = c("income", "expenses"), data = data_gbar,
dataDateFormat = "MM/YYYY", minPeriod = "MM")
amBarplot(x = "day", y = c("income", "expenses"), data = data_gbar,
dataDateFormat = "DD/MM/YYYY")
# Change groups colors
amBarplot(x = "year", y = c("income", "expenses"), data = data_gbar,
groups_color = c("#87cefa", "#c7158"))
# Regular stacked bars
amBarplot(x = "year", y = c("income", "expenses"), data = data_gbar, stack_type = "regular")
# 100% stacked bars
amBarplot(x = "year", y = c("income", "expenses"), data = data_gbar, stack_type = "100")
# Layered bars
amBarplot(x = "year", y = c("income", "expenses"), data = data_gbar, layered = TRUE)
# Data with row names
dataset <- data.frame(get(x = "USArrests", pos = "package:datasets"))
amBarplot(y = c("Murder", "Assault", "UrbanPop", "Rape"), data = dataset, stack_type = "regular")
# Round values
amBarplot(x = "year", y = c("in", "ex"), data = data_gbar, precision = 0)
## End(Not run)