Giter Club home page Giter Club logo

waterfalls's Introduction

waterfalls

R package to create waterfall charts

waterfalls's People

Contributors

gregleleu avatar hughparsonage avatar robert-koetsier avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

waterfalls's Issues

order of bars when using `.coord_flip()`

If I flip my waterfalls around using coord_flip() in ggplot2 the "start" bar is on the bottom and the total on top, when most would expect to read top to bottom.

For example:

waterfall(
  tibble(category = letters[1:5],
         value = c(200, -20, 4, 20, -5)),
  calc_total = TRUE,
  fill_by_sign = FALSE,
  put_rect_text_outside_when_value_below = 50
) + coord_flip() 

image

I would typically add + scale_x_reverse() to my ggplot object, but in this case it results in:

Scale for 'x' is already present. Adding another scale for 'x', which will replace the existing
scale.
Error: Discrete value supplied to continuous scale
In addition: Warning messages:
1: In Ops.factor(x) : ‘-’ not meaningful for factors
2: Transformation introduced infinite values in continuous x-axis 

Adjust the font size of the text in X-axis

I love the package a lot. However, I didn't find a way to adjust the size of the text in X axis? Am I missing something or will this be in the future version?

Thanks,

text gets positioned off when `coord_flip()`

I'm loving your waterfalls package and am so glad I don't have to build these up from scratch! Thank you so much for making this available.

I've run into an interesting edge scenario, however. I like to flip my waterfalls around using coord_flip() in ggplot2. But when I do, the text labels get bumped around.

For example:

waterfall(
  tibble(category = letters[1:5],
         value = c(200, -20, 4, 20, -5)),
  calc_total = TRUE,
  fill_by_sign = FALSE,
  put_rect_text_outside_when_value_below = 50
) + coord_flip() 

image

I'm beginning to dig into the code and if I cook up a solution I'll send a PR. But I wanted to register the issue first.

Unable to add y axis titles

Love the chart, but I want to add some axis labels and I can't. Reproducible example:

waterfall(values = round(rnorm(5), 1), labels = letters[1:5], calc_total = TRUE) + ylab("Why can't I add a y axis label?")

R version 4.4.0 (2024-04-24 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 22000)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8 LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C LC_TIME=English_United States.utf8

time zone: America/Chicago
tzcode source: internal

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

other attached packages:
[1] ggplot2_3.5.1 waterfalls_1.0.0

loaded via a namespace (and not attached):
[1] vctrs_0.6.5 cli_3.6.2 rlang_1.1.3 generics_0.1.3 textshaping_0.3.7 glue_1.7.0
[7] labeling_0.4.3 colorspace_2.1-0 rprojroot_2.0.4 ragg_1.3.0 scales_1.3.0 fansi_1.0.6
[13] grid_4.4.0 munsell_0.5.1 tibble_3.2.1 lifecycle_1.0.4 compiler_4.4.0 dplyr_1.1.4
[19] pkgconfig_2.0.3 here_1.0.1 rstudioapi_0.16.0 farver_2.1.1 systemfonts_1.0.6 R6_2.5.1
[25] tidyselect_1.2.1 utf8_1.2.4 pillar_1.9.0 magrittr_2.0.3 tools_4.4.0 withr_3.0.0
[31] gtable_0.3.5

lost rect_text_labels when coord_cartesian used to limit y range, with fix

My gratitude to you for this package.
I made a small hack to work around a limitation:
Using coord_cartesian(ylim=c(0.6, 0.72)) to zoom in to plot caused my rect_text_labels to land outside of the range and disappear. Not currently in a position to submit a pull request due to work firewall, but my fix was to replace rect_text_labels_anchor = "centre" with rect_text_labels_anchor = 0.05 and treat it as numeric. Then replace the two places that 0.5 were used to set it with the var name. Now, I can set it at 0.9 when combined with the coord_cartesian and the rect_text_labels no longer drop.

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.