Title: | A Heatmap-Like Visualization Tool |
---|---|
Description: | A data visualization design that provides comparison between two (Double) data sources (usually on a par with each other) on one reformed heatmap, while inheriting 'ggplot2' features. |
Authors: | Youzhi Yu [aut, cre], Trent Buskirk [aut, ths] |
Maintainer: | Youzhi Yu <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.1.2 |
Built: | 2025-02-14 04:41:26 UTC |
Source: | https://github.com/pursuitofdatascience/ggdoubleheat |
The heatcircle geom is used to create the two concentric circles that use luminance to show the values from two sources on the same plot.
geom_heat_circle( outside, outside_name = NULL, outside_colors = c("#FED7D8", "#FE8C91", "#F5636B", "#E72D3F", "#C20824"), inside, inside_name = NULL, inside_colors = c("gray100", "gray85", "gray50", "gray35", "gray0"), r = 2 * sqrt(2), ... )
geom_heat_circle( outside, outside_name = NULL, outside_colors = c("#FED7D8", "#FE8C91", "#F5636B", "#E72D3F", "#C20824"), inside, inside_name = NULL, inside_colors = c("gray100", "gray85", "gray50", "gray35", "gray0"), r = 2 * sqrt(2), ... )
outside |
The column name for the outside portion of heatcircle. |
outside_name |
The label name (in quotes) for the legend of the outside
rendering. Default is |
outside_colors |
A color vector, usually as hex codes. |
inside |
The column name for the inside portion of heatcircle. |
inside_name |
The label name (in quotes) for the legend of the inside
rendering. Default is |
inside_colors |
A color vector, usually as hex codes. |
r |
The value that controls how large of the inside portion with respect
to the outside one. When |
... |
|
A heatcircle comparing two data sources.
# heatcircle with categorical variables only library(ggplot2) data <- data.frame(x = rep(c("a", "b", "c"), 3), y = rep(c("d", "e", "f"), 3), outside_values = rep(c(1,5,7),3), inside_values = rep(c(2,3,4),3)) ggplot(data, aes(x,y)) + geom_heat_circle(outside = outside_values, inside = inside_values) # Making the inside smaller by setting r to be larger. ggplot(data, aes(x,y)) + geom_heat_circle(outside = outside_values, inside = inside_values, r = 5) # heatcircle with numeric variables only data <- data.frame(x = rep(c(1, 2, 3), 3), y = rep(c(1, 2, 3), 3), outside_values = rep(c(1,5,7),3), inside_values = rep(c(2,3,4),3)) ggplot(data, aes(x,y)) + geom_heat_circle(outside = outside_values, inside = inside_values) # heatcircle 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), outside_values = rep(c(1,5,7),3), inside_values = rep(c(2,3,4),3)) ggplot(data, aes(x,y)) + geom_heat_circle(outside = outside_values, inside = inside_values)
# heatcircle with categorical variables only library(ggplot2) data <- data.frame(x = rep(c("a", "b", "c"), 3), y = rep(c("d", "e", "f"), 3), outside_values = rep(c(1,5,7),3), inside_values = rep(c(2,3,4),3)) ggplot(data, aes(x,y)) + geom_heat_circle(outside = outside_values, inside = inside_values) # Making the inside smaller by setting r to be larger. ggplot(data, aes(x,y)) + geom_heat_circle(outside = outside_values, inside = inside_values, r = 5) # heatcircle with numeric variables only data <- data.frame(x = rep(c(1, 2, 3), 3), y = rep(c(1, 2, 3), 3), outside_values = rep(c(1,5,7),3), inside_values = rep(c(2,3,4),3)) ggplot(data, aes(x,y)) + geom_heat_circle(outside = outside_values, inside = inside_values) # heatcircle 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), outside_values = rep(c(1,5,7),3), inside_values = rep(c(2,3,4),3)) ggplot(data, aes(x,y)) + geom_heat_circle(outside = outside_values, inside = inside_values)
The heatgrid geom is used to create a modified heat map that uses luminance to show the values from two sources on the same plot.
geom_heat_grid( outside, outside_name = NULL, outside_colors = c("#FED7D8", "#FE8C91", "#F5636B", "#E72D3F", "#C20824"), inside, inside_name = NULL, inside_colors = c("gray100", "gray85", "gray50", "gray35", "gray0"), r = 2 * sqrt(2), ... )
geom_heat_grid( outside, outside_name = NULL, outside_colors = c("#FED7D8", "#FE8C91", "#F5636B", "#E72D3F", "#C20824"), inside, inside_name = NULL, inside_colors = c("gray100", "gray85", "gray50", "gray35", "gray0"), r = 2 * sqrt(2), ... )
outside |
The column name for the outside portion of heatgrid. |
outside_name |
The label name (in quotes) for the legend of the outside
rendering. Default is |
outside_colors |
A color vector, usually as hex codes. |
inside |
The column name for the inside portion of heatgrid. |
inside_name |
The label name (in quotes) for the legend of the inside
rendering. Default is |
inside_colors |
A color vector, usually as hex codes. |
r |
The value that controls how large of the inside portion with respect
to the outside one. When |
... |
|
A heatgrid comparing two data sources.
# heatgrid with categorical variables only library(ggplot2) data <- data.frame(x = rep(c("a", "b", "c"), 3), y = rep(c("d", "e", "f"), 3), outside_values = rep(c(1,5,7),3), inside_values = rep(c(2,3,4),3)) ggplot(data, aes(x,y)) + geom_heat_grid(outside = outside_values, inside = inside_values) # Making the inside smaller by setting r to be larger. ggplot(data, aes(x,y)) + geom_heat_grid(outside = outside_values, inside = inside_values, r = 5) # heatgrid with numeric variables only data <- data.frame(x = rep(c(1, 2, 3), 3), y = rep(c(1, 2, 3), 3), outside_values = rep(c(1,5,7),3), inside_values = rep(c(2,3,4),3)) ggplot(data, aes(x,y)) + geom_heat_grid(outside = outside_values, inside = inside_values) # heatgrid 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), outside_values = rep(c(1,5,7),3), inside_values = rep(c(2,3,4),3)) ggplot(data, aes(x,y)) + geom_heat_grid(outside = outside_values, inside = inside_values)
# heatgrid with categorical variables only library(ggplot2) data <- data.frame(x = rep(c("a", "b", "c"), 3), y = rep(c("d", "e", "f"), 3), outside_values = rep(c(1,5,7),3), inside_values = rep(c(2,3,4),3)) ggplot(data, aes(x,y)) + geom_heat_grid(outside = outside_values, inside = inside_values) # Making the inside smaller by setting r to be larger. ggplot(data, aes(x,y)) + geom_heat_grid(outside = outside_values, inside = inside_values, r = 5) # heatgrid with numeric variables only data <- data.frame(x = rep(c(1, 2, 3), 3), y = rep(c(1, 2, 3), 3), outside_values = rep(c(1,5,7),3), inside_values = rep(c(2,3,4),3)) ggplot(data, aes(x,y)) + geom_heat_grid(outside = outside_values, inside = inside_values) # heatgrid 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), outside_values = rep(c(1,5,7),3), inside_values = rep(c(2,3,4),3)) ggplot(data, aes(x,y)) + geom_heat_grid(outside = outside_values, inside = inside_values)
The heattriangle geom is used to create the two triangles split by a diagonal line of a rectangle that use luminance to show the values from two sources on the same plot.
geom_heat_tri( lower, lower_name = NULL, lower_colors = c("#FED7D8", "#FE8C91", "#F5636B", "#E72D3F", "#C20824"), upper, upper_name = NULL, upper_colors = c("gray100", "gray85", "gray50", "gray35", "gray0"), ... )
geom_heat_tri( lower, lower_name = NULL, lower_colors = c("#FED7D8", "#FE8C91", "#F5636B", "#E72D3F", "#C20824"), upper, upper_name = NULL, upper_colors = c("gray100", "gray85", "gray50", "gray35", "gray0"), ... )
lower |
The column name for the lower portion of heattriangle. |
lower_name |
The label name (in quotes) for the legend of the lower
rendering. Default is |
lower_colors |
A color vector, usually as hex codes. |
upper |
The column name for the upper portion of heattriangle. |
upper_name |
The label name (in quotes) for the legend of the upper
rendering. Default is |
upper_colors |
A color vector, usually as hex codes. |
... |
|
A heattriangle with the main diagonal split by a line within each unit.
# heattriangle with categorical variables only library(ggplot2) data <- data.frame(x = rep(c("a", "b", "c"), 3), y = rep(c("d", "e", "f"), 3), lower_values = rep(c(1,5,7),3), upper_values = rep(c(2,3,4),3)) ggplot(data, aes(x,y)) + geom_heat_tri(lower = lower_values, upper = upper_values) # heatcircle with numeric variables only data <- data.frame(x = rep(c(1, 2, 3), 3), y = rep(c(1, 2, 3), 3), lower_values = rep(c(1,5,7),3), upper_values = rep(c(2,3,4),3)) ggplot(data, aes(x,y)) + geom_heat_tri(lower = lower_values, upper = upper_values) # heatcircle 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), lower_values = rep(c(1,5,7),3), upper_values = rep(c(2,3,4),3)) ggplot(data, aes(x,y)) + geom_heat_tri(lower = lower_values, upper = upper_values)
# heattriangle with categorical variables only library(ggplot2) data <- data.frame(x = rep(c("a", "b", "c"), 3), y = rep(c("d", "e", "f"), 3), lower_values = rep(c(1,5,7),3), upper_values = rep(c(2,3,4),3)) ggplot(data, aes(x,y)) + geom_heat_tri(lower = lower_values, upper = upper_values) # heatcircle with numeric variables only data <- data.frame(x = rep(c(1, 2, 3), 3), y = rep(c(1, 2, 3), 3), lower_values = rep(c(1,5,7),3), upper_values = rep(c(2,3,4),3)) ggplot(data, aes(x,y)) + geom_heat_tri(lower = lower_values, upper = upper_values) # heatcircle 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), lower_values = rep(c(1,5,7),3), upper_values = rep(c(2,3,4),3)) ggplot(data, aes(x,y)) + geom_heat_tri(lower = lower_values, upper = upper_values)
ggDoubleHeat, which is a ggplot2 extension, provides
visualization for a reformed heatmap. Instead of facetting heatmaps by data
sources, they can be combined together for making one single heatmap,
generated by geom_heat_*()
functions built in the package. Prior to
using the package, users should load ggplot2.
All functions in the package are named as geom_heat_*()
, making the
naming convention consistent. Also, the arguments for functions are
relatively similar, although with slight variations due to where a specific
argument will connect to the position of the rendering plot. Users should
reference the documentation and possibly run examples presented in the help
file when trying to understand what each argument means visually.
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_emojis
pitts_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_tg
pitts_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 authors 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_heat_*()' 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_tg
states_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 authors of the package.
Plot Themes
theme_heat( base_size = 11, base_family = "", base_line_size = base_size/22, base_rect_size = base_size/22 )
theme_heat( 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 heat theme to all plots generated by using the ggDoubleHeat package.