Description Usage Arguments Functions Examples
A custom barplot separated into one init function and two different barplot functions so it can easily be added to other plots or used in combination with points, lines and so on.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | init_barplot(
x = names(y),
y,
xlim = NULL,
ylim = NULL,
include0 = TRUE,
ylab = "",
xlab = "",
main = "barplot",
las = 2
)
lines_barplot(x = names(y), y, lwd = 3, col = "black")
rect_barplot(x = names(y), y, width = 0.7, col = "black")
|
x, y |
double, for x also a character vector is allowed, if only one argument is provided it is taken as y and its names as x. If x can be converted to double it is used as x, if not it is only used as labels. |
xlim, ylim |
limits for both axes; if |
include0 |
logic, if TRUE y axis includes origin |
ylab |
a title for the y axis |
xlab |
a title for the x axis |
main |
an overall title for the plot |
las |
numeric, see |
lwd |
line width as used in |
col |
bar color |
width |
specifies the box width (with = 1 leaves no space between the bars) |
init_barplot
: draws an empty plot for rect_barplot and
lines_barplot
lines_barplot
: is a plotting function based on lines
rect_barplot
: is a plotting function based on rect
1 2 3 4 5 6 7 8 9 10 | x <- 10 + rnorm(40)
names(x) <- 1901:1940
# rect_barplot:
init_barplot(x)
rect_barplot(x, width = 0.5)
# lines_barplot:
init_barplot(x)
lines_barplot(x, lwd = 3)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.