| Title: | Taichi-Diagram Visualization for Two Data Sources |
|---|---|
| Description: | A data visualization design that compares two (usually on a par with each other) data sources on one grid of taichi (yin-yang) diagrams, where the two interlocking fish of every symbol are filled by the two sources, while inheriting 'ggplot2' features. |
| Authors: | Youzhi Yu [aut, cre] |
| Maintainer: | Youzhi Yu <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 0.1.0 |
| Built: | 2026-06-24 10:32:31 UTC |
| Source: | https://github.com/cran/ggtaichi |
The taichi geom turns each cell of a heatmap-like grid into a taichi
(yin-yang) diagram. The two interlocking "fish" of the diagram use luminance
to show the values from two data sources on the same plot, so four
dimensions of data can be expressed at once: the x and y
position of every taichi symbol plus the yin and yang values
that fill its two halves.
geom_taichi( yin, yin_name = NULL, yin_colors = c("gray100", "gray85", "gray50", "gray35", "gray0"), yang, yang_name = NULL, yang_colors = c("#FED7D8", "#FE8C91", "#F5636B", "#E72D3F", "#C20824"), ... )geom_taichi( yin, yin_name = NULL, yin_colors = c("gray100", "gray85", "gray50", "gray35", "gray0"), yang, yang_name = NULL, yang_colors = c("#FED7D8", "#FE8C91", "#F5636B", "#E72D3F", "#C20824"), ... )
yin |
The column name for the yin (dark) fish of the taichi symbol. |
yin_name |
The label name (in quotes) for the legend of the yin
rendering. Default is |
yin_colors |
A color vector, usually as hex codes. |
yang |
The column name for the yang (light) fish of the taichi symbol. |
yang_name |
The label name (in quotes) for the legend of the yang
rendering. Default is |
yang_colors |
A color vector, usually as hex codes. |
... |
|
A taichi diagram comparing two data sources.
# taichi with categorical variables only library(ggplot2) data <- data.frame(x = rep(c("a", "b", "c"), 3), y = rep(c("d", "e", "f"), 3), yin_values = rep(c(1,5,7),3), yang_values = rep(c(2,3,4),3)) ggplot(data, aes(x,y)) + geom_taichi(yin = yin_values, yang = yang_values) # taichi with numeric variables only data <- data.frame(x = rep(c(1, 2, 3), 3), y = rep(c(1, 2, 3), 3), yin_values = rep(c(1,5,7),3), yang_values = rep(c(2,3,4),3)) ggplot(data, aes(x,y)) + geom_taichi(yin = yin_values, yang = yang_values) # taichi with a mixture of numeric and categorical variables data <- data.frame(x = rep(c("a", "b", "c"), 3), y = rep(c(1, 2, 3), 3), yin_values = rep(c(1,5,7),3), yang_values = rep(c(2,3,4),3)) ggplot(data, aes(x,y)) + geom_taichi(yin = yin_values, yang = yang_values)# taichi with categorical variables only library(ggplot2) data <- data.frame(x = rep(c("a", "b", "c"), 3), y = rep(c("d", "e", "f"), 3), yin_values = rep(c(1,5,7),3), yang_values = rep(c(2,3,4),3)) ggplot(data, aes(x,y)) + geom_taichi(yin = yin_values, yang = yang_values) # taichi with numeric variables only data <- data.frame(x = rep(c(1, 2, 3), 3), y = rep(c(1, 2, 3), 3), yin_values = rep(c(1,5,7),3), yang_values = rep(c(2,3,4),3)) ggplot(data, aes(x,y)) + geom_taichi(yin = yin_values, yang = yang_values) # taichi with a mixture of numeric and categorical variables data <- data.frame(x = rep(c("a", "b", "c"), 3), y = rep(c(1, 2, 3), 3), yin_values = rep(c(1,5,7),3), yang_values = rep(c(2,3,4),3)) ggplot(data, aes(x,y)) + geom_taichi(yin = yin_values, yang = yang_values)
The most popular Emoji of a given week in a given category from the Meltwater
Tweet sample. They can be rendered by using "richtext" with
annotate().
pitts_emojispitts_emojis
An object of class character of length 270.
A data set containing the 30-week incidence rates of COVID related categories
from week 1 starting from June 1, 2020 to week 30
that ended in the last Sunday of the year in Pittsburgh Metropolitan
Statistical Area (MSA). The data columns are introduced below. One quick note
about the columns of the data set: week_start as a column is present
in the data set for illustration purposes, reminding users what week
column is. In other words, it does not participate any visualization.
pitts_tgpitts_tg
A data frame with 270 rows and 6 columns:
Metropolitan statistical area (Pittsburgh only).
week 1 to week 30.
The Monday date of the week started.
9 Covid-related categories in total.
weekly tweets percentage (%) in the MSA falling into each category.
weekly Google search percentage (%) in the MSA falling into each category.
Just like states_tg, Google is processed from Google Health
API, and Twitter from Meltwater, a Twitter vendor. Both data sources are
processed by the author of the package.
The default ggplot2 plots give certain amount of padding for both continuous and discrete variables. Due to this padding, it makes the plots generated from ‘geom_taichi()' look like there is something missing. Depends on users’ preference, they can remove the "empty space" by using this function. The only thing users need to figure out is whether the 'x' and 'y' scales are continuous or discrete.
remove_padding(x = "c", y = "d", ...)remove_padding(x = "c", y = "d", ...)
x |
x-axis scale, if it is continuous scale, input "c"; discrete, "d". |
y |
y-axis scale, if it is continuous scale, input "c"; discrete, "d". |
... |
... |
remove_padding
A data set containing the 30-week incidence rates of COVID related categories
from week 1 starting from June 1, 2020 to week 30
that ended in the last Sunday of the year in 4 states (Florida, Missouri,
New York, and Texas). The data columns are introduced below. One quick note
about the columns of the data set: week_start as a column is present
in the data set for illustration purposes, reminding users what week
column is. In other words, it does not participate any visualization.
states_tgstates_tg
A data frame with 1116 rows and 6 columns:
state
week 1 to week 30.
The Monday date of the week started.
9 Covid-related categories in total.
weekly tweets percentage (%) in state falling into each category.
weekly Google search percentage (%) in state falling into each category.
Just like pitts_tg, Google is processed from Google Health
API, and Twitter from Meltwater, a Twitter vendor. Both data sources are
processed by the author of the package.
A light theme tuned for the taichi grid: it bottoms the legends, drops the panel grid and axis ticks, and gives the canvas a soft off-white background reminiscent of rice paper.
theme_taichi( base_size = 11, base_family = "", base_line_size = base_size/22, base_rect_size = base_size/22 )theme_taichi( base_size = 11, base_family = "", base_line_size = base_size/22, base_rect_size = base_size/22 )
base_size |
base font size |
base_family |
base font family |
base_line_size |
base size for line elements |
base_rect_size |
base size for rect elements |
Adding a taichi theme to all plots generated by using the ggtaichi package.