All Projects → rivasiker → ggHoriPlot

rivasiker / ggHoriPlot

Licence: other
A user-friendly, highly customizable R package for building horizon plots in ggplot2

Programming Languages

r
7636 projects

Projects that are alternatives of or similar to ggHoriPlot

jcolors
A set of color palettes I like (or can at least tolerate)
Stars: ✭ 24 (-79.13%)
Mutual labels:  ggplot2, r-package
Naniar
Tidy data structures, summaries, and visualisations for missing data
Stars: ✭ 557 (+384.35%)
Mutual labels:  ggplot2, r-package
Bayesplot
bayesplot R package for plotting Bayesian models
Stars: ✭ 276 (+140%)
Mutual labels:  ggplot2, r-package
TDAstats
R pipeline for computing persistent homology in topological data analysis. See https://doi.org/10.21105/joss.00860 for more details.
Stars: ✭ 26 (-77.39%)
Mutual labels:  ggplot2, r-package
Ggparliament
Simple parliament plots using ggplot2
Stars: ✭ 130 (+13.04%)
Mutual labels:  ggplot2, r-package
cusumcharter
Easier CUSUM control charts. Returns simple CUSUM statistics, CUSUMs with control limit calculations, and function to generate faceted CUSUM Control Charts
Stars: ✭ 17 (-85.22%)
Mutual labels:  ggplot2, r-package
Ggextra
📊 Add marginal histograms to ggplot2, and more ggplot2 enhancements
Stars: ✭ 299 (+160%)
Mutual labels:  ggplot2, r-package
mapr
Map species occurrence data
Stars: ✭ 34 (-70.43%)
Mutual labels:  ggplot2, r-package
Gratia
ggplot-based graphics and useful functions for GAMs fitted using the mgcv package
Stars: ✭ 102 (-11.3%)
Mutual labels:  ggplot2, r-package
Tidymv
Tidy Model Visualisation for Generalised Additive Models
Stars: ✭ 25 (-78.26%)
Mutual labels:  ggplot2, r-package
Ggpointdensity
📈 📊 Introduces geom_pointdensity(): A Cross Between a Scatter Plot and a 2D Density Plot.
Stars: ✭ 286 (+148.7%)
Mutual labels:  ggplot2, r-package
Ggdist
Visualizations of distributions and uncertainty
Stars: ✭ 197 (+71.3%)
Mutual labels:  ggplot2, r-package
Tidybayes
Bayesian analysis + tidy data + geoms (R package)
Stars: ✭ 557 (+384.35%)
Mutual labels:  ggplot2, r-package
Plotly
An interactive graphing library for R
Stars: ✭ 2,096 (+1722.61%)
Mutual labels:  ggplot2, r-package
sportyR
R package for drawing regulation playing surfaces for several sports
Stars: ✭ 84 (-26.96%)
Mutual labels:  ggplot2, r-package
r-whatsapp-analysis-parte1
Análisis de texto y visualización de datos con R, de conversaciones de WhatsApp, primer parte. Uso de librería rwhatsapp.
Stars: ✭ 22 (-80.87%)
Mutual labels:  ggplot2
mchtoolbox
⛔ ARCHIVED ⛔ What the Package Does (Title Case)
Stars: ✭ 13 (-88.7%)
Mutual labels:  r-package
bruceR
📦 BRoadly Useful Convenient and Efficient R functions that BRing Users Concise and Elegant R data analyses.
Stars: ✭ 110 (-4.35%)
Mutual labels:  r-package
value-investing-studies
Data Analysis Studies on Value Investing
Stars: ✭ 66 (-42.61%)
Mutual labels:  ggplot2
NBA-Shot-Charts
Create NBA shot charts using data scrapped from stats.nba.com and R package ggplot2.
Stars: ✭ 33 (-71.3%)
Mutual labels:  ggplot2

ggHoriPlot: horizon plots in ggplot2

R-CMD-check CRAN downloads codecov

This package allows building horizon plots in ggplot2. You can learn more about the package in vignette("ggHoriPlot").

Installation

You can install ggHoriPlot from CRAN via:

install.packages("ggHoriPlot")

You can also install the development version of the package from GitHub with the following command:

#install.packages("devtools")
devtools::install_github("rivasiker/ggHoriPlot")

Basic example

Load the libraries:

library(tidyverse)
library(ggHoriPlot) 
library(ggthemes)

Load the dataset and calculate the cutpoints and origin:

utils::data(climate_CPH)

cutpoints <- climate_CPH  %>% 
  mutate(
    outlier = between(
      AvgTemperature, 
      quantile(AvgTemperature, 0.25, na.rm=T)-
        1.5*IQR(AvgTemperature, na.rm=T),
      quantile(AvgTemperature, 0.75, na.rm=T)+
        1.5*IQR(AvgTemperature, na.rm=T))) %>% 
  filter(outlier)

ori <- sum(range(cutpoints$AvgTemperature))/2
sca <- seq(range(cutpoints$AvgTemperature)[1], 
           range(cutpoints$AvgTemperature)[2], 
           length.out = 7)[-4]

round(ori, 2) # The origin
#> [1] 6.58

round(sca, 2) # The horizon scale cutpoints
#> [1] -12.11  -5.88   0.35  12.81  19.05  25.28

Build the horizon plots in ggplot2 using geom_horizon():

climate_CPH %>% ggplot() +
  geom_horizon(aes(date_mine, 
                   AvgTemperature,
                   fill = ..Cutpoints..), 
               origin = ori, horizonscale = sca) +
  scale_fill_hcl(palette = 'RdBu', reverse = T) +
  facet_grid(Year~.) +
  theme_few() +
  theme(
    panel.spacing.y=unit(0, "lines"),
    strip.text.y = element_text(size = 7, angle = 0, hjust = 0),
    axis.text.y = element_blank(),
    axis.title.y = element_blank(),
    axis.ticks.y = element_blank(),
    panel.border = element_blank()
    ) +
  scale_x_date(expand=c(0,0), 
               date_breaks = "1 month", 
               date_labels = "%b") +
  xlab('Date') +
  ggtitle('Average daily temperature in Copenhagen', 
          'from 1995 to 2019')

Learn more

You can check out the full functionality of ggHoriPlot in the following guides:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].