8000 Revert "Switched figures to grayscale for book" · codingbooks/tidy-text-mining@c282d6c · GitHub
[go: up one dir, main page]

Skip to content

Commit c282d6c

Browse files
David RobinsonDavid Robinson
authored andcommitted
Revert "Switched figures to grayscale for book"
This reverts commit 5ab8b09.
1 parent 5ab8b09 commit c282d6c

File tree

4 files changed

+32
-32
lines changed

4 files changed

+32
-32
lines changed

04-word-combinations.Rmd

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ bigram_tf_idf %>%
116116
top_n(12, tf_idf) %>%
117117
ungroup() %>%
118118
mutate(bigram = reorder(bigram, tf_idf)) %>%
119-
ggplot(aes(bigram, tf_idf)) +
119+
ggplot(aes(bigram, tf_idf, fill = book)) +
120120
geom_col(show.legend = FALSE) +
121121
facet_wrap(~ book, ncol = 2, scales = "free") +
122122
coord_flip() +
< 10000 /td>
@@ -172,8 +172,8 @@ not_words %>%
172172
arrange(desc(abs(contribution))) %>%
173173
head(20) %>%
174174
mutate(word2 = reorder(word2, contribution)) %>%
175-
ggplot(aes(word2, n * score)) +
176-
geom_col() +
175+
ggplot(aes(word2, n * score, fill = n * score > 0)) +
176+
geom_col(show.legend = FALSE) +
177177
xlab("Words preceded by \"not\"") +
178178
ylab("Sentiment score * number of occurrences") +
179179
coord_flip()
@@ -202,8 +202,8 @@ negated_words %>%
202202
word2 = reorder(paste(word2, word1, sep = "__"), contribution)) %>%
203203
group_by(word1) %>%
204204
top_n(12, abscontribution) %>%
205-
ggplot(aes(word2, contribution)) +
206-
geom_col() +
205+
ggplot(aes(word2, contribution, fill = n * score > 0)) +
206+
geom_col(show.legend = FALSE) +
207207
facet_wrap(~ word1, scales = "free") +
208208
scale_x_discrete(labels = function(x) gsub("__.+$", "", x)) +
209209
xlab("Words preceded by negation term") +
@@ -266,7 +266,7 @@ a <- grid::arrow(type = "closed", length = unit(.15, "inches"))
266266
ggraph(bigram_graph, layout = "fr") +
267267
geom_edge_link(aes(edge_alpha = n), show.legend = FALSE,
268268
arrow = a, end_cap = circle(.07, 'inches')) +
269-
geom_node_point(color = "gray", size = 5) +
269+
geom_node_point(color = "lightblue", size = 5) +
270270
geom_node_text(aes(label = name), vjust = 1, hjust = 1) +
271271
theme_void()
272272
```
@@ -310,7 +310,7 @@ visualize_bigrams <- function(bigrams) {
310310
graph_from_data_frame() %>%
311311
ggraph(layout = "fr") +
312312
geom_edge_link(aes(edge_alpha = n), show.legend = FALSE, arrow = a) +
313-
geom_node_point(color = "gray", size = 5) +
313+
geom_node_point(color = "lightblue", size = 5) +
314314
geom_node_text(aes(label = name), vjust = 1, hjust = 1) +
315315
theme_void()
316316
}
@@ -458,7 +458,7 @@ word_cors %>%
458458
graph_from_data_frame() %>%
459459
ggraph(layout = "fr") +
460460
geom_edge_link(aes(edge_alpha = correlation), show.legend = FALSE) +
461-
geom_node_point(color = "gray", size = 5) +
461+
geom_node_point(color = "lightblue", size = 5) +
462462
geom_node_text(aes(label = name), repel = TRUE) +
463463
theme_void()
464464
```

05-document-term-matrices.Rmd

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ ap_sentiments %>%
9393
filter(n >= 200) %>%
9494
mutate(n = ifelse(sentiment == "negative", -n, n)) %>%
9595
mutate(term = reorder(term, n)) %>%
96-
ggplot(aes(term, n)) +
96+
ggplot(aes(term, n, fill = sentiment)) +
9797
geom_bar(stat = "identity") +
9898
ylab("Contribution to sentiment") +
9999
coord_flip()
@@ -143,7 +143,7 @@ inaug_tf_idf %>%
143143
top_n(10, tf_idf) %>%
144144
ungroup() %>%
145145
mutate(term = reorder(term, tf_idf)) %>%
146-
ggplot(aes(term, tf_idf)) +
146+
ggplot(aes(term, tf_idf, fill = document)) +
147147
geom_col(show.legend = FALSE) +
148148
facet_wrap(~ document, scales = "free") +
149149
coord_flip() +
@@ -338,7 +338,7 @@ stock_tf_idf %>%
338338
top_n(8, tf_idf) %>%
339339
ungroup() %>%
340340
mutate(word = reorder(word, tf_idf)) %>%
341-
ggplot(aes(word, tf_idf)) +
341+
ggplot(aes(word, tf_idf, fill = company)) +
342342
geom_col(show.legend = FALSE) +
343343
facet_wrap(~ company, scales = "free") +
344344
coord_flip() +
@@ -404,8 +404,8 @@ It might be interesting to examine which company has the most news with "litigio
404404
stock_sentiment_count %>%
405405
mutate(score = (positive - negative) / (positive + negative)) %>%
406406
mutate(company = reorder(company, score)) %>%
407-
ggplot(aes(company, score)) +
408-
geom_col() +
407+
ggplot(aes(company, score, fill = score > 0)) +
408+
geom_col(show.legend = FALSE) +
409409
coord_flip() +
410410
labs(x = "Company",
411411
y = "Positivity score among 20 recent news articles")

06-topic-models.Rmd

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ ap_top_terms <- ap_topics %>%
8181
8282
ap_top_terms %>%
8383
mutate(term = reorder(term, beta)) %>%
84-
ggplot(aes(term, beta)) +
85-
geom_col() +
84+
ggplot(aes(term, beta, fill = factor(topic))) +
85+
geom_col(show.legend = FALSE) +
8686
facet_wrap(~ topic, scales = "free") +
8787
coord_flip()
8888
```
@@ -246,8 +246,8 @@ library(ggplot2)
246246
247247
top_terms %>%
248248
mutate(term = reorder(term, beta)) %>%
249-
ggplot(aes(term, beta)) +
250-
geom_col() +
249+
ggplot(aes(term, beta, fill = factor(topic))) +
250+
geom_col(show.legend = FALSE) +
251251
facet_wrap(~ topic, scales = "free") +
252252
coord_flip()
253253
```
@@ -345,7 +345,7 @@ assignments %>%
345345
mutate(percent = n / sum(n)) %>%
346346
ggplot(aes(consensus, title, fill = percent)) +
347347
geom_tile() +
348-
scale_fill_gradient2(high = "black", label = percent_format()) +
348+
scale_fill_gradient2(high = "red", label = percent_format()) +
349349
theme_minimal() +
350350
theme(axis.text.x = element_text(angle = 90, hjust = 1),
351351
panel.grid = element_blank()) +

09-usenet.Rmd

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ tf_idf %>%
147147
top_n(12, tf_idf) %>%
148148
ungroup() %>%
149149
mutate(word = reorder(word, tf_idf)) %>%
150-
ggplot(aes(word, tf_idf)) +
151-
geom_col() +
150+
ggplot(aes(word, tf_idf, fill = newsgroup)) +
151+
geom_col(show.legend = FALSE) +
152152
facet_wrap(~ newsgroup, scales = "free") +
153153
ylab("tf-idf") +
154154
coord_flip()
@@ -162,8 +162,8 @@ plot_tf_idf <- function(d) {
162162
group_by(newsgroup) %>%
163163
top_n(10, tf_idf) %>%
164164
mutate(word = reorder(word, tf_idf)) %>%
165-
ggplot(aes(word, tf_idf)) +
166-
geom_col() +
165+
ggplot(aes(word, tf_idf, fill = newsgroup)) +
166+
geom_col(show.legend = FALSE) +
167167
facet_wrap(~ newsgroup, scales = "free") +
168168
ylab("tf-idf") +
169169
coord_flip()
@@ -197,7 +197,7 @@ newsgroup_cors %>%
197197
graph_from_data_frame() %>%
198198
ggraph(layout = "fr") +
199199
geom_edge_link(aes(alpha = correlation, width = correlation)) +
200-
geom_node_point(size = 6, color = "gray") +
200+
geom_node_point(size = 6, color = "lightblue") +
201201
geom_node_text(aes(label = name), repel = TRUE) +
202202
theme_void()
203203
```
@@ -241,7 +241,7 @@ sci_lda %>%
241241
top_n(8, beta) %>%
242242
ungroup() %>%
243243
mutate(term = reorder(term, beta)) %>%
244-
ggplot(aes(term, beta)) +
244+
ggplot(aes(term, beta, fill = factor(topic))) +
245245
geom_col(show.legend = FALSE) +
246246
facet_wrap(~ topic, scales = "free_y") +
247247
coord_flip()
@@ -279,8 +279,8 @@ newsgroup_sentiments <- words_by_newsgroup %>%
279279
280280
newsgroup_sentiments %>%
281281
mutate(newsgroup = reorder(newsgroup, score)) %>%
282-
ggplot(aes(newsgroup, score)) +
283-
geom_col() +
282+
ggplot(aes(newsgroup, score, fill = score > 0)) +
283+
geom_col(show.legend = FALSE) +
284284
coord_flip() +
285285
ylab("Average sentiment score")
286286
```
@@ -308,8 +308,8 @@ contributions %>%
308308
mutate(abscontribution = abs(contribution)) %>%
309309
top_n(25, abscontribution) %>%
310310
mutate(word = reorder(word, contribution)) %>%
311-
ggplot(aes(word, contribution)) +
312-
geom_col() +
311+
ggplot(aes(word, contribution, fill = contribution > 0)) +
312+
geom_col(show.legend = FALSE) +
313313
coord_flip()
314314
```
315315

@@ -334,8 +334,8 @@ top_sentiment_words %>%
334334
ungroup() %>%
335335
mutate(newsgroup = reorder(newsgroup, contribution),
336336
word = reorder(paste(word, newsgroup, sep = "__"), contribution)) %>%
337-
ggplot(aes(word, contribution)) +
338-
geom_col() +
337+
ggplot(aes(word, contribution, fill = contribution > 0)) +
338+
geom_col(show.legend = FALSE) +
339339
scale_x_discrete(labels = function(x) gsub("__.+$", "", x)) +
340340
facet_wrap(~ newsgroup, scales = "free") +
341341
coord_flip() +
@@ -429,8 +429,8 @@ usenet_bigram_counts %>%
429429
top_n(10, abscontribution) %>%
430430
ungroup() %>%
431431
mutate(word2 = reorder(paste(word2, word1, sep = "__"), contribution)) %>%
432-
ggplot(aes(word2, contribution)) +
433-
geom_col() +
432+
ggplot(aes(word2, contribution, fill = contribution > 0)) +
433+
geom_col(show.legend = FALSE) +
434434
facet_wrap(~ word1, scales = "free", nrow = 3) +
435435
scale_x_discrete(labels = function(x) gsub("__.+$", "", x)) +
436436
xlab("Words preceded by a negation") +

0 commit comments

Comments
 (0)
0