-
Notifications
You must be signed in to change notification settings - Fork 0
/
.Rhistory
129 lines (129 loc) · 6.59 KB
/
.Rhistory
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
packrat::on()
install.packages("devtools") # so we can install from github
library("devtools")
install_github("ropensci/plotly") # plotly is part of ropensci
library(reshape2)
library(plotly)
py <- plotly(username="daniellekellier", key="55LZ2igwjD1aQWBfcAyE")
pp <- function (n,r=4) {
x <- seq(-r*pi, r*pi, len=n)
df <- expand.grid(x=x, y=x)
df$r <- sqrt(df$x^2 + df$y^2)
df$z <- cos(df$r^2)*exp(-df$r/6)
df
}
data_xyz <- pp(100)
View(data_xyz)
data_z <- acast(data_xyz, x~y, value.var = "z")
data_z
View(data_z)
plot_ly(z = data_z, type = "surface")
library(rvest)
library(colorspace)
crayonURL <- "https://en.wikipedia.org/wiki/List_of_Crayola_crayon_colors"
temp <- crayonURL %>%
read_html %>%
html_nodes("table")
all_crayons <- html_table(temp[[1]]) %>% mutate(Color = tolower(gsub("[^a-zA-Z0-9]","",Color)), Hexadecimal = substr(Hexadecimal, 1,7)) ## Just the "legend" table
pack_64 <- read.csv("~/Desktop/crayola_colors.csv",header = F, col.names = "Color") %>% mutate(Color = tolower(gsub("[^a-zA-Z0-9]","",Color))) %>% left_join(all_crayons)
pack_64[pack_64$Color == "violet",2:ncol(pack_64)] <- all_crayons[all_crayons$Color=="violetii",2:ncol(pack_64)]
pack_64[pack_64$Color == "blue",2:ncol(pack_64)] <- all_crayons[all_crayons$Color=="blueiii",2:ncol(pack_64)]
pack_64[pack_64$Color == "chestnut",2:ncol(pack_64)] <- all_crayons[all_crayons$Color=="indianred",2:ncol(pack_64)]
pack_64[pack_64$Color == "gold",2:ncol(pack_64)] <- all_crayons[all_crayons$Color=="goldii",2:ncol(pack_64)]
pack_64[pack_64$Color == "lavender",2:ncol(pack_64)] <- all_crayons[all_crayons$Color=="lavenderii",2:ncol(pack_64)]
gsub("[^a-zA-Z0-9]","",x)
pack_64$num_range <- seq(1,nrow(pack_64))
install.packages("rvest")
library(rvest)
library(colorspace)
crayonURL <- "https://en.wikipedia.org/wiki/List_of_Crayola_crayon_colors"
temp <- crayonURL %>%
read_html %>%
html_nodes("table")
all_crayons <- html_table(temp[[1]]) %>% mutate(Color = tolower(gsub("[^a-zA-Z0-9]","",Color)), Hexadecimal = substr(Hexadecimal, 1,7)) ## Just the "legend" table
pack_64 <- read.csv("~/Desktop/crayola_colors.csv",header = F, col.names = "Color") %>% mutate(Color = tolower(gsub("[^a-zA-Z0-9]","",Color))) %>% left_join(all_crayons)
pack_64[pack_64$Color == "violet",2:ncol(pack_64)] <- all_crayons[all_crayons$Color=="violetii",2:ncol(pack_64)]
pack_64[pack_64$Color == "blue",2:ncol(pack_64)] <- all_crayons[all_crayons$Color=="blueiii",2:ncol(pack_64)]
pack_64[pack_64$Color == "chestnut",2:ncol(pack_64)] <- all_crayons[all_crayons$Color=="indianred",2:ncol(pack_64)]
pack_64[pack_64$Color == "gold",2:ncol(pack_64)] <- all_crayons[all_crayons$Color=="goldii",2:ncol(pack_64)]
pack_64[pack_64$Color == "lavender",2:ncol(pack_64)] <- all_crayons[all_crayons$Color=="lavenderii",2:ncol(pack_64)]
gsub("[^a-zA-Z0-9]","",x)
pack_64$num_range <- seq(1,nrow(pack_64))
# ggplot(pack_64, aes(xmin = 0, xmax = 1, ymin = num_range, ymax = num_range + 0.7, fill = factor(num_range))) + geom_rect() + scale_fill_manual(values = pack_64$Hexadecimal) + theme(legend.position = "none")
x <- hex2RGB(pack_64$Hexadecimal, gamma = FALSE)
storage.mode(x@coords) <- "numeric" # as(..., "LUV") doesn't like integers for some reason
y <- as(x, "LAB")
DF <- as.data.frame(y@coords)
library(rvest)
library(colorspace)
library(dplyr)
crayonURL <- "https://en.wikipedia.org/wiki/List_of_Crayola_crayon_colors"
temp <- crayonURL %>%
read_html %>%
html_nodes("table")
all_crayons <- html_table(temp[[1]]) %>% mutate(Color = tolower(gsub("[^a-zA-Z0-9]","",Color)), Hexadecimal = substr(Hexadecimal, 1,7)) ## Just the "legend" table
pack_64 <- read.csv("~/Desktop/crayola_colors.csv",header = F, col.names = "Color") %>% mutate(Color = tolower(gsub("[^a-zA-Z0-9]","",Color))) %>% left_join(all_crayons)
pack_64[pack_64$Color == "violet",2:ncol(pack_64)] <- all_crayons[all_crayons$Color=="violetii",2:ncol(pack_64)]
pack_64[pack_64$Color == "blue",2:ncol(pack_64)] <- all_crayons[all_crayons$Color=="blueiii",2:ncol(pack_64)]
pack_64[pack_64$Color == "chestnut",2:ncol(pack_64)] <- all_crayons[all_crayons$Color=="indianred",2:ncol(pack_64)]
pack_64[pack_64$Color == "gold",2:ncol(pack_64)] <- all_crayons[all_crayons$Color=="goldii",2:ncol(pack_64)]
pack_64[pack_64$Color == "lavender",2:ncol(pack_64)] <- all_crayons[all_crayons$Color=="lavenderii",2:ncol(pack_64)]
gsub("[^a-zA-Z0-9]","",x)
pack_64$num_range <- seq(1,nrow(pack_64))
# ggplot(pack_64, aes(xmin = 0, xmax = 1, ymin = num_range, ymax = num_range + 0.7, fill = factor(num_range))) + geom_rect() + scale_fill_manual(values = pack_64$Hexadecimal) + theme(legend.position = "none")
x <- hex2RGB(pack_64$Hexadecimal, gamma = FALSE)
storage.mode(x@coords) <- "numeric" # as(..., "LUV") doesn't like integers for some reason
y <- as(x, "LAB")
DF <- as.data.frame(y@coords)
View(DF)
DF$col <- pack_64$Hexadecimal
View(DF)
?ggplotly
plot_ly(DF, x = ~B, y = ~A, z = ~L, color = ~col, colors = ~col)
?scatter3d
plot_ly(DF, x = ~B, y = ~A, z = ~L, color = ~col, colors = DF$col)
?ggplotly
plot_ly(DF, x = ~B, y = ~A, z = ~L, color = ~col)
plot_ly(DF, x = ~B, y = ~A, z = ~L, colors = DF$col)
plot_ly(DF, x = ~B, y = ~A, z = ~L, colors = list(DF$col))
plot_ly(DF, x = ~B, y = ~A, z = ~L, color = list(~col))
plot_ly(DF, x = ~B, y = ~A, z = ~L, color = ~col, colors = DF$col)
View(DF)
write.csv(DF, "~/Desktop/crayola_cielab.csv")
plot_ly(DF, x = ~B, y = ~A, z = ~L, color = ~col, colors = DF$col) %>%
add_markers()
plot_ly(DF, x = ~B, y = ~A, z = ~L, color = ~col, colors = ~col) %>%
add_markers() %>%
layout(scene = list(xaxis = list(title = 'b*'),
yaxis = list(title = 'a*'),
zaxis = list(title = 'L*')))
plot_ly(DF, x = ~B, y = ~A, z = ~L, type="scatter", mode="markers", color = ~col, marker = list(color=col)) %>%
add_markers() %>%
layout(scene = list(xaxis = list(title = 'b*'),
yaxis = list(title = 'a*'),
zaxis = list(title = 'L*')))
plot_ly(DF, x = ~B, y = ~A, z = ~L, type="scatter", mode="markers", color = ~col, marker = list(color=col)) %>%
layout(scene = list(xaxis = list(title = 'b*'),
yaxis = list(title = 'a*'),
zaxis = list(title = 'L*')))
?add_markers
plot_ly(DF, x = ~B, y = ~A, z = ~L,
marker = list(color = ~col, colorscale = col)) %>%
add_markers() %>%
layout(scene = list(xaxis = list(title = 'b*'),
yaxis = list(title = 'a*'),
zaxis = list(title = 'L*')))
chart_link <- plotly_POST(p, filename="crayola_64_pack")
p <- plot_ly(DF, x = ~B, y = ~A, z = ~L,
marker = list(color = ~col, colorscale = col)) %>%
add_markers() %>%
layout(scene = list(xaxis = list(title = 'b*'),
yaxis = list(title = 'a*'),
zaxis = list(title = 'L*')))
chart_link <- plotly_POST(p, filename="crayola_64_pack")
chart_link
?plotly_POST
packrat::snapshot()
install.packages("knitr")
packrat::restore()
setwd("~/Documents/repo/crayola_color")