GithubHelp home page GithubHelp logo

flying-sheep / ggplot.multistats Goto Github PK

View Code? Open in Web Editor NEW
10.0 3.0 0.0 76 KB

Multiple Summary Statistics for Binned Stats/Geometries

License: GNU General Public License v3.0

R 100.00%
r ggplot2 statistics ggplot2-geom

ggplot.multistats's Introduction

CRAN badge Workflow badge

ggplot.multistats

ggplot.multistats currently provides stat_summaries_hex and some helpers.

stat_summaries_hex is similar to ggplot2::stat_summary_hex, but allows specifying multiple stats using the funs parameter (see Example).

Installation

ggplot.multistats is on CRAN.

install.packages('ggplot.multistats')

You can also install the development version from GitHub:

# install.packages('devtools')
devtools::install_github('flying-sheep/ggplot.multistats')

Example

Specify a summary variable using the z aesthetic and specify a list of funs to provide after_stats for you:

library(ggplot2)
library(ggplot.multistats)

ggplot(iris, aes(Sepal.Width, Sepal.Length)) +
  stat_summaries_hex(
    aes(z = Petal.Width, fill = after_stat(median), alpha = after_stat(n)),
    funs = c('median', n = 'length'),
    bins = 5
  )

ggplot.multistats's People

Contributors

flying-sheep avatar pre-commit-ci[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ggplot.multistats's Issues

Unable To Reproduce Example, z Aesthetic Is Dropped:

stat_summaries_hex seems to be exactly what I'm looking for!

However, I'm unable to reproduce the example and am wondering if I'm missing something or if an update has caused some incompatibility? When specifying both fill and alpha values with stats, only the alpha value appears to make an effect. If I remove the alpha parameter, then the hex bins are colored by n but only when alpha is not specified.

In addition, I'm receiving the warning message that the z aesthetic was dropped during statistical transformation - I assume that shouldn't happen, as the z aesthetic is what I'm trying to transform!

I have ggplot.multistats 1.0.0 and ggplot2 3.4.0 installed.

library(ggplot2)
library(ggplot.multistats)

ggplot(iris, aes(Sepal.Width, Sepal.Length)) +
  stat_summaries_hex(
    aes(z = Petal.Width, fill = stat(median), alpha = stat(n)),
    funs = c('median', n = 'length'),
    bins = 5
  )

image

Use with categorical variable

Hi, this is an excellent package.

Do you have any suggestion on what's the best way to represent a categorical variable as well?
E.g. if in any hexagon I wanted to see which of my factor levels is most represented as a colour from a qualitative palette.

Cheers!

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.