-
Notifications
You must be signed in to change notification settings - Fork 0
/
R_script_0024.R
48 lines (28 loc) · 863 Bytes
/
R_script_0024.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Code by @AmirMotefaker
# R Bar Charts
# Bar Charts
# Use the barplot() function to draw a vertical bar chart
# x-axis values
x <- c("A", "B", "C", "D")
# y-axis values
y <- c(2, 4, 6, 8)
barplot(y, names.arg = x)
# Bar Color
# Use the col parameter to change the color of the bars
x <- c("A", "B", "C", "D")
y <- c(2, 4, 6, 8)
barplot(y, names.arg = x, col = "red")
# Density / Bar Texture
# To change the bar texture, use the density parameter
x <- c("A", "B", "C", "D")
y <- c(2, 4, 6, 8)
barplot(y, names.arg = x, density = 10)
# Bar Width
# Use the width parameter to change the width of the bars
x <- c("A", "B", "C", "D")
y <- c(2, 4, 6, 8)
# Horizontal Bars
# If you want the bars to be displayed horizontally instead of vertically, use horiz=TRUE
x <- c("A", "B", "C", "D")
y <- c(2, 4, 6, 8)
barplot(y, names.arg = x, horiz = TRUE)