Giter Club home page Giter Club logo

ggjoy's Introduction

ggjoy

Build Status Coverage Status CRAN_Status_Badge CRAN_Downloads_Badge

The ggjoy package has been deprecated. Please switch over to ggridges. To port from ggjoy to ggridges, make the following substitutions in your code:

ggjoy function ggridges function
geom_joy geom_density_ridges
geom_joy2 geom_density_ridges2
geom_joy_gradient geom_density_ridges_gradient
stat_joy stat_density_ridges
theme_joy theme_ridges

All other ggjoy functions (e.g., geom_ridgeline) exist under the same name in the ggridges package.

ggjoy's People

Contributors

clauswilke avatar jonathon-love avatar tjmahr avatar yonicd avatar yutannihilation avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ggjoy's Issues

do not display colours in example

all density plot in joy theme were displayed in gray, and the colour cannot be changed using scale_fill_manual
here is my session info
`Session info ----------------------------------------------------------------------------------
setting value
version R version 3.3.2 (2016-10-31)
system x86_64, linux-gnu
ui RStudio (1.0.44)
language (EN)
collate en_US.UTF-8
tz Asia/Shanghai
date 2017-07-12

Packages --------------------------------------------------------------------------------------
package * version date source
colorspace 1.3-2 2016-12-14 CRAN (R 3.3.2)
curl 2.3 2016-11-24 CRAN (R 3.3.2)
devtools * 1.12.0 2016-12-05 CRAN (R 3.3.2)
digest 0.6.12 2017-01-27 cran (@0.6.12)
ggjoy * 0.1 2017-07-12 Github (3402761)
ggplot2 * 2.2.1 2016-12-30 cran (@2.2.1)
git2r 0.16.0 2016-11-20 CRAN (R 3.3.2)
gtable 0.2.0 2016-02-26 CRAN (R 3.3.2)
httr 1.2.1 2016-07-03 CRAN (R 3.3.2)
labeling 0.3 2014-08-23 CRAN (R 3.3.2)
lazyeval 0.2.0 2016-06-12 cran (@0.2.0)
memoise 1.0.0 2016-01-29 CRAN (R 3.3.2)
munsell 0.4.3 2016-02-13 CRAN (R 3.3.2)
plyr 1.8.4 2016-06-08 CRAN (R 3.3.2)
R6 2.2.0 2016-10-05 cran (@2.2.0)
Rcpp 0.12.11 2017-05-22 cran (@0.12.11)
rlang 0.1.1 2017-05-18 cran (@0.1.1)
scales 0.4.1 2016-11-09 CRAN (R 3.2.3)
tibble 1.3.3 2017-05-28 cran (@1.3.3)
withr 1.0.2 2016-06-20 CRAN (R 3.3.2) `

possible to drop purrr dependency?

hi,

i notice that ggjoy imports purrr, which in turn imports:

magrittr
tibble
rlang
Rcpp

this is in order to user purrr::reduce, which is only used in one place.

would you consider replacing this purrr::reduce() call? or accepting a PR to replace it?

reducing the number of imports ggjoy uses would improve the situation for us.

with thanks

respect facet_*(..., scales = "free_x")

The facet_ functions allow the x and y limits to vary within each panel by using the scales argument.

ggjoy used to respect the per-panel free scales, but in the most recent update, it lost this ability.

library(dplyr)
iris_long <- iris %>%
  tidyr::gather(variable, value, -Species)

library(ggjoy)
ggplot(iris_long) +
  aes(x = value, y = Species) +
  geom_joy(rel_min_height = 0.01) +
  facet_wrap("variable")
#> Picking joint bandwidth of 0.575

unnamed-chunk-2-1

ggplot(iris_long) +
  aes(x = value, y = Species) +
  geom_joy(rel_min_height = 0.01) +
  facet_wrap("variable", scales = "free_x")
#> Picking joint bandwidth of 0.575

unnamed-chunk-2-2

# A plot where this scaling is respected
with_density <- iris_long %>%
  group_by(Species, variable) %>%
  do(ggplot2:::compute_density(.$value, NULL)) %>%
  ungroup() %>%
  rename(value = x)

ggplot(with_density) +
  aes(x = value, y = Species, height = scaled, group = Species) +
  geom_ridgeline(scale = 1.8) +
  facet_wrap("variable", scales = "free_x")

unnamed-chunk-2-3

devtools::session_info(pkgs = "ggjoy")
#> Session info -------------------------------------------------------------
#>  setting  value                       
#>  version  R version 3.4.0 (2017-04-21)
#>  system   x86_64, mingw32             
#>  ui       RStudio (1.0.143)           
#>  language (EN)                        
#>  collate  English_United States.1252  
#>  tz       America/Chicago             
#>  date     2017-07-14
#> Packages -----------------------------------------------------------------
#>  package      * version date       source                           
#>  colorspace     1.3-2   2016-12-14 CRAN (R 3.4.0)                   
#>  dichromat      2.0-0   2013-01-24 CRAN (R 3.4.0)                   
#>  digest         0.6.12  2017-01-27 CRAN (R 3.4.0)                   
#>  ggjoy        * 0.1     2017-07-14 Github (clauswilke/ggjoy@3ba0469)
#>  ggplot2      * 2.2.1   2016-12-30 CRAN (R 3.4.0)                   
#>  graphics     * 3.4.0   2017-04-21 local                            
#>  grDevices    * 3.4.0   2017-04-21 local                            
#>  grid           3.4.0   2017-04-21 local                            
#>  gtable         0.2.0   2016-02-26 CRAN (R 3.4.0)                   
#>  labeling       0.3     2014-08-23 CRAN (R 3.4.0)                   
#>  lazyeval       0.2.0   2016-06-12 CRAN (R 3.4.0)                   
#>  magrittr       1.5     2014-11-22 CRAN (R 3.4.0)                   
#>  MASS           7.3-47  2017-02-26 CRAN (R 3.4.0)                   
#>  methods      * 3.4.0   2017-04-21 local                            
#>  munsell        0.4.3   2016-02-13 CRAN (R 3.4.0)                   
#>  plyr           1.8.4   2016-06-08 CRAN (R 3.4.0)                   
#>  RColorBrewer   1.1-2   2014-12-07 CRAN (R 3.4.0)                   
#>  Rcpp           0.12.11 2017-05-22 CRAN (R 3.4.0)                   
#>  reshape2       1.4.2   2016-10-22 CRAN (R 3.4.0)                   
#>  rlang          0.1.1   2017-05-18 CRAN (R 3.4.0)                   
#>  scales         0.4.1   2016-11-09 CRAN (R 3.4.0)                   
#>  stats        * 3.4.0   2017-04-21 local                            
#>  stringi        1.1.5   2017-04-07 CRAN (R 3.4.0)                   
#>  stringr        1.2.0   2017-02-18 CRAN (R 3.4.0)                   
#>  tibble       * 1.3.3   2017-05-28 CRAN (R 3.4.0)                   
#>  tools          3.4.0   2017-04-21 local                            
#>  utils        * 3.4.0   2017-04-21 local

Error in factor(quantile) : object 'quantile' not found

I want to use stat = "density" instead of stat = "joy" with geom_joy_gradient but I get the following error. What should I do?

ggplot(iris, aes(x=Sepal.Length, y=Species, fill=factor(..quantile..), height = ..density..)) +
+   geom_joy_gradient(stat = "density", calc_ecdf = TRUE, quantiles = c(0.05, 0.95)) +
+   scale_fill_manual(name = "Probability\nranges",
+                     values = c("red", "grey80", "blue")) +
+   theme_joy() + scale_y_discrete(expand = c(0.01, 0))

Warning: Ignoring unknown parameters: calc_ecdf, quantiles
Error in factor(quantile) : object 'quantile' not found

EDIT 1:
My main concern is;
You mentioned stat_joy calculates densities different than stat_density in the documentation.
I want to show the quantiles and maximum density value in a table. So, I need the densities calculated by stat_joy. Can you show a mini-example how to calculate densities as in stat_joy?

EDIT 2:
Claus said [1] that;

You're trying to get stat_density something to do it can't, namely calculating quantiles. See the warning "Ignoring unkown parameters..."? That's stat_density telling you it doesn't understand what you want.

Isn't that possible to have the same functionality also for stat = "density"? (A feature request may be?)

Help plotting density curves

I want to plot a density curve instead of a line graph for each of my series. I know this isn't an "issue" persay, I would love any help you might be able to give.

Love the package!

Error: could not find function "scale_fill_cyclical"

Hi, thanks for releasing this, looks great! Ran into a small issue when trying to use scale_fill_cyclical() as below:

ggplot(diamonds, aes(x = price, y = cut)) +
    geom_joy(scale = 4) + theme_joy() +
    scale_y_discrete(expand = c(0.01, 0)) + 
    scale_x_continuous(expand = c(0, 0)) +
    ggjoy::scale_fill_cyclical(values = c("#00CCFF", "#f46b42"))

Returns: Error: 'scale_fill_cyclical' is not an exported object from 'namespace:ggjoy'

> sessionInfo()
 R version 3.3.2 (2016-10-31) 
 Platform: x86_64-apple-darwin13.4.0 (64-bit)
 Running under: macOS Sierra 10.12.5

 locale:
 [1] C

 attached base packages:
 [1] stats     graphics  grDevices utils     datasets  methods   base     

 other attached packages:
 [1] ggjoy_0.2.0                   bindrcpp_0.2                  tidyquant_0.5.1               quantmod_0.4-10              
 [5] TTR_0.23-2                    PerformanceAnalytics_1.4.3541 xts_0.10-0                    zoo_1.8-0                    
 [9] lubridate_1.6.0               xlsx_0.5.7                    xlsxjars_0.6.1                rJava_0.9-8                  
 [13] knitr_1.16                    leaflet.extras_0.2            leaflet_1.1.0.9000            ggmap_2.7                    

 [17] gridExtra_2.2.1               ggthemes_3.4.0                dplyr_0.7.2                   purrr_0.2.2.2                

 [21] readr_1.1.1                   tidyr_0.6.3                   tibble_1.3.3                  ggplot2_2.2.1                
 [25] tidyverse_1.1.1              

 loaded via a namespace (and not attached):
 [1] httr_1.2.1        maps_3.2.0        jsonlite_1.5      modelr_0.1.1      shiny_1.0.3       assertthat_0.2.0  sp_1.2-5         
 [8] cellranger_1.1.0  lattice_0.20-35   glue_1.1.1        digest_0.6.12     rvest_0.3.2       colorspace_1.3-2  htmltools_0.3.6  
 [15] httpuv_1.3.5      plyr_1.8.4        psych_1.7.5       pkgconfig_2.0.1   broom_0.4.2       haven_1.1.0       xtable_1.8-2     
 [22] scales_0.4.1      jpeg_0.1-8        lazyeval_0.2.0    mnormt_1.5-5      proto_1.0.0       magrittr_1.5      readxl_1.0.0     
 [29] mime_0.5          nlme_3.1-131      forcats_0.2.0     xml2_1.1.1        foreign_0.8-69    tools_3.3.2       hms_0.3          
 [36] geosphere_1.5-5   RgoogleMaps_1.4.1 stringr_1.2.0     munsell_0.4.3     rlang_0.1.1       grid_3.3.2        rjson_0.2.15     
 [43] htmlwidgets_0.9   crosstalk_1.0.0   labeling_0.3      bitops_1.0-6      gtable_0.2.0      curl_2.8.1        reshape2_1.4.2   
 [50] R6_2.2.2          bindr_0.1         Quandl_2.8.0      stringi_1.1.5     parallel_3.3.2    Rcpp_0.12.12      mapproj_1.2-5    
 [57] png_0.1-7

Thanks in advance!

use density plots from ggs_density?

Hello, I realize your package is brand new but I was wondering how easy/hard it would be to use density plots created by ggs_density with geom_joy? I am creating many density plots from ggs objects that I use to create density plots of my mcmc chains (see example figure).

ggfin <- ggs(fin)
p = ggs_density(ggfin, family = "beta1mu")
p + theme_classic()+
labs(x=expression(bold(Bottlek["Terr Stream T34"]" "~Day^{-1})))+
ylab("Probability Density")

primealgae_darkstr_k1_t234fin

color quantiles

I really enjoy plotting things with ggjoy. coloring quantiles is really a nice feature, but unfortunately I can't make it work.

When I add the quantile function I get the error:

Error in f(..., self = self) : Aesthetics can not vary along a ridgeline

it works without the fill.

I am not sure what I am doing wrong or if my data is not the way it should be.

Here is my function.
ggplot(data = p_joy1,aes(x = p,y=as.factor(generation),fill=as.factor(..quantile..))) + geom_joy(calc_ecdf =TRUE,quantiles = c(0.2,0.8)) + scale_fill_manual(name= 'test',values = c('red','grey','blue'))+ scale_y_discrete(expand = c(0.01,0)) + theme_joy()

joy-histograms for discrete data

Excellent work with this package! I wonder if you would be inclined to add a new geom using histograms rather than density plots, especially for discrete data such as Likert scale measures.

I like to make "outlined" histograms like so:

library(ggplot2)
bw = 1000
ggplot(diamonds, aes(x=price)) +
  geom_histogram(binwidth=bw, fill="white", col=NA) +
  geom_step(aes(y=..count..), stat="bin", binwidth=bw,
            position=position_nudge(x=-bw/2), pad=TRUE)

It would be great to be able to stack these like joyplots.

R >= 3.3 ?

hi,

we're loving ggjoy, and have made use of it in the descriptives for jamovi (www.jamovi.org), however in the most recent version you've bumped it to require R >= 3.3

this makes it tricky for us, because we provide jamovi for ubuntu xenial (+mint, etc.) and these only ship with R 3.2. my solution is normally to just patch whatever package back to R >= 3.2, and ship that with jamovi, but that's less than ideal.

anyhow, just wondering what prompted the change.

with thanks

Limiting ridgelines to the data

Is it possible to limit the lines of the ridgelines to the data? That is, instead of across the entire range of data, just to the minimum and maximum values?

A documentation clarification

Incredible package. Thank you.

The @description of geom_ridgeline states (emphasize added):

Plots the sum of the y and height aesthetics versus x, filling the area between y and y + height with a color. Thus, the data mapped onto y and onto height must be in the same units. If you want relative scaling of the heights, you can use geom_joy with stat = "identity".

Is it possible to elaborate on this at all? If we set height in geom_ridgeline like this:

library(ggplot2)
library(ggjoy)

d <- data.frame(x = rep(1:5, 3), Year = c(rep(1979, 5), rep(1980, 5), rep(1981, 5)),
                height = c(0, 1, 3, 4, 0, 1, 2, 3, 5, 4, 0, 5, 4, 4, 1))

ggplot(d, aes(x, y = Year, height = height, group = Year)) + 
  geom_ridgeline(scale = 0.2) 

We get this plot:
image

Using different scales for y and height seem to be an issue. But if do something like this with geom_joy it is ok:

ggplot(d, aes(x, y = Year, height = height, group = Year)) + 
  geom_joy(stat = "identity", scale = 1)

image
Now obviously I am missing something because these are the same plot. However there is no similar stipulation the the ggjoy documentation. So my question is one of convention. When using ggjoy, if we are plotting raw data and stacking them, it is best to use the same variable as y but if we are plotting data distributions, it is ok to deviate from this rule because density (or count) is assumed? For example:
ggplot(iris, aes(x = Sepal.Length, y = Species)) + geom_joy()
image

My goal is to plot a time series where I set height to continuous variable, plot a year on the y-axis and then plot day-month on the x-axis. This provides a VERY nice visualization of data by year. I can do this (basically the 1st or 2nd example). However the documentation has thrown me and I wanted to make sure that I was on the right side visualization conventions. So ultimately the question is, in what instances, if any,is it ok for the height and y argument to be of different scales?

Make work for non-density plots

One possible idea for further package development:

library(ggplot2); library(ggjoy); require(dplyr); require(raster)
d = volcano %>% raster() %>% rasterToPoints() %>% as_data_frame()
head(d,3)
#> # A tibble: 3 x 3
#>             x         y layer
#>         <dbl>     <dbl> <dbl>
#> 1 0.008196721 0.9942529   100
#> 2 0.024590164 0.9942529   100
#> 3 0.040983607 0.9942529   101
ggplot(d, aes(x=x, y=y, group=y, height=layer)) + geom_joy(scale=4)
#> Warning in max(data$height): no non-missing arguments to max; returning -
#> Inf
#> Error in eval(expr, envir, enclos): object 'height' not found

Installation Failure

When installing from the installation command on R 3.4, the following fatal error occurs:

  • installing source package ‘ggjoy’ ...
    ** R
    Error in .install_package_code_files(".", instdir) :
    files in 'Collate' field missing from '/tmp/Rtmp724pj3/devtools36d870e81c1b/clauswilke-ggjoy-bab95c7/R':
    stats.R
    ERROR: unable to collate and parse R files for package ‘ggjoy’

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.