-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworking versions.R
74 lines (42 loc) · 2.9 KB
/
working versions.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
library(ggplot2)
library(ggjoy)
library(readr)
library(cairo)
X2017salarytwo3 <- read_csv("C:/Users/mmccrae/Downloads/2017 Canadian Mine Salaries, Wages and Benefits Report to joy plot - Data for R.csv")
X2017salarytwo3$position <- factor(X2017salarytwo3$position, levels = c("General Manager", "Mine Manager", "Mine Superintendent", "Mill Superintendent", "Mech/El Superintendent", "Mine Foreman", "Mill Foreman", "Chief Engineer", "Mine Engineer", "Senior Geologist", "Mine Geologist", "Metallurgist", "Chemist", "Environmental Coordinator", "Environmental Technician", "Safety/Health", "Engineering Technician", "Surveyor", "Personnel Manager", "Accountant", "Accounting Clerk", "Administrative Assistant", "Secretary", "Purchasing Agent", "Warehouse Clerk", "Expeditor", "Buyer"))
X2017salarytwo3$position <- factor(X2017salarytwo3$position, levels = rev(levels(X2017salarytwo3$position)))
CairoPNG('working101.png', width = 800, height = 700)
ggplot(X2017salarytwo3, aes(x = pay, y = positionwavg)) +
geom_joy(scale = 2) + theme_minimal() +
scale_fill_cyclical(values = c("#3030D0", "#9090F0"))+
scale_y_discrete(name=NULL, expand = c(0.03, 0)) + # will generally have to set the `expand` option
scale_x_continuous(name="Pay", limits=c(0, 350000), expand = c(0, 0), labels=scales::dollar) # for both axes to remove unneeded padding
dev.off()
############## WORKING WITH COLOUR
library(ggplot2)
library(ggjoy)
library(readr)
library(cairo)
X2017salarytwo3 <- read_csv("C:/Users/mmccrae/Downloads/2017 Canadian Mine Salaries, Wages and Benefits Report to joy plot - Data for R.csv")
CairoPNG('working101.png', width = 800, height = 700)
ggplot(X2017salarytwo3, aes(x = pay, y = reorder(positionwavg, pay))) +
geom_joy2(col = "black", fill = "lightblue", scale = 2.4) +
theme_minimal() +
scale_y_discrete(name=NULL, expand = c(0.03, 0)) + # will generally have to set the `expand` option
scale_x_continuous(name="Pay", limits=c(0, 350000), expand = c(0, 0), labels=scales::dollar) # for both axes to remove unneeded padding
dev.off()
############## trying to alternate colour COULDN'T GET TO WORK
library(ggplot2)
library(ggjoy)
library(readr)
library(cairo)
X2017salarytwo3 <- read_csv("C:/Users/mmccrae/Downloads/2017 Canadian Mine Salaries, Wages and Benefits Report to joy plot - Data for R.csv")
#CairoPNG('working101.png', width = 800, height = 700)
ggplot(X2017salarytwo3, aes(x = pay, y = reorder(positionwavg, pay))) +
geom_joy2 (scale = 2.4) +
theme_minimal() +
scale_fill_manual(values=rep(c('gray', 'lightblue'), length(unique(X2017salarytwo3$order))/2)) +
scale_y_discrete(name=NULL, expand = c(0.03, 0)) + # will generally have to set the `expand` option
scale_x_continuous(name="Pay", limits=c(0, 350000), expand = c(0, 0), labels=scales::dollar) # for both axes to remove unneeded padding
#dev.off()
WD