-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlotBar.r
More file actions
58 lines (43 loc) · 1.8 KB
/
PlotBar.r
File metadata and controls
58 lines (43 loc) · 1.8 KB
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
49
50
51
52
53
54
55
56
57
# Install packages required to run this script
list.of.packages <- c("dplyr", "stringr", "ggplot2", "reshape2")
new.packages <- list.of.packages[!(list.of.packages %in% installed.packages()[,"Package"])]
if(length(new.packages)) install.packages(new.packages)
# Load Libraries
library(dplyr)
library(stringr)
library(ggplot2)
library(reshape2)
drawBarA <- function(inputs, graphTitle, yLabel) {
print(graphTitle)
print(inputs)
df_molten <- melt(inputs, "Tools")
print(df_molten)
yLimit <- max(df_molten$value)+5
df_molten$Tools <- factor(df_molten$Tools, levels=df_molten[order(-df_molten$value), "Tools"])
ggplot(df_molten, aes(Tools, value, fill = variable, label=value)) +
geom_bar(stat="identity", position = "dodge", width=0.3, fill="royalblue1") +
ggtitle(graphTitle) +
ylab(yLabel) +
scale_y_continuous(expand = c(0.01,0), limits = c(0, yLimit)) +
scale_x_discrete(expand = c(0.01,0))
}
drawHorizontalBarA <- function(inputs, graphTitle, yLabel) {
plot <- drawBarA(inputs, graphTitle, yLabel)
plot <- plot + coord_flip() + geom_text(aes(y=(value + 1.0)))
plot <- plot + theme(
panel.grid = element_blank(),
plot.title = element_text(size = 20, family="Times", face="bold", color = "cornflowerblue"),
axis.text = element_text(size = 10, face = "bold"),
strip.text = element_text(size = 10, face = "bold", family="Times", colour = "orange"),
panel.background = element_rect(fill="white"),
legend.position = "bottom",
axis.line = element_line(colour = "black", size = 0.2, linetype = "solid"))
print(plot)
}
main <- function () {
dataset <- read.table("/home/weapon-x/Documents/R/latestreport.txt")
print(dataset)
drawHorizontalBarA(dataset, "Project Management Tool", "Product Teams")
}
## Starting point of the script
main()