GithubHelp home page GithubHelp logo

erocoar / ggpol Goto Github PK

View Code? Open in Web Editor NEW
102.0 102.0 10.0 1.39 MB

๐ŸŒ Parliament diagrams and more for ggplot2

Home Page: https://erocoar.github.io/ggpol/

License: Other

R 100.00%
dataviz ggplot-extension ggplot2 r visualization

ggpol's People

Contributors

erocoar avatar martinschmelzer avatar romagnolid 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

ggpol's Issues

geom_boxjitter: can we skip drawing the jitter points?

Hello,

I want to keep only the half boxplot and replace the jitter points with the points from the ggbeeswarm package. Is it possible? Could you add an option to turn on/off the plotting of all the points?

In the example below, I can disable the color of all the jitter points but it leaves an empty space between the boxplot and the beeswarm.

Thanks!

library(ggplot2)
library(ggbeeswarm)
library(ggpol)

ggplot(iris, aes(y = Petal.Width)) + 
  geom_boxjitter(jitter.shape = NA, 
                 jitter.color = NA,
                 jitter.height = 0, 
                 jitter.width = 0,
                 outlier.color = NA, 
                 errorbar.draw = TRUE) +
  geom_quasirandom(
    aes(x = 1, color = Species),
    width = 0.25,
    size = 2, 
    groupOnX = TRUE, alpha = 0.7) +
  scale_color_brewer(palette = 'Set2') +
  theme_classic()

Created on 2019-05-18 by the reprex package (v0.3.0)

geom_boxjitter fails without explicit attaching the package

The following ggplot2 code works as expected even without attaching the package first:

set.seed(221)
df <- data.frame(score = rgamma(150, 4, 1),
                 gender = sample(c("M", "F"), 150, replace = TRUE),
                 genotype = factor(sample(1:3, 150, replace = TRUE)))

ggplot2::ggplot(df, ggplot2::aes(x = gender, y = score)) +
  ggplot2::geom_boxplot() ## works

However, the same does not work with geom_boxjitter:

ggplot2::ggplot(df, ggplot2::aes(x = gender, y = score)) +
  ggpol::geom_boxjitter() ##fails
## Error in alpha(data$fill, data$alpha) : could not find function "alpha"

We need to attach the package first, before it works:

library("ggpol")
ggplot2::ggplot(df, ggplot2::aes(x = gender, y = score)) +
  geom_boxjitter() ##works

Then it also works with :::

ggplot2::ggplot(df, ggplot2::aes(x = gender, y = score)) +
  ggpol::geom_boxjitter()  ## works now

Failed to install ggpol after the latest commit

Hi,

I encountered the following error (R 3.6.1):

* installing *source* package 'ggpol' ...
** using staged installation
** R
Error in .install_package_code_files(".", instdir) : 
files in '/AppData/Local/Temp/Rtmpsdn2EM/R.INSTALL66303af073c1/ggpol/R' missing from 'Collate' field:
  geom_half_boxplot.R
  geom_half_point.R
  stat-half-point.R
ERROR: unable to collate and parse R files for package 'ggpol'

Can you please check? Thanks!

Could not find function "geom_parliament"

Hey. I have installed the library, following the steps written on the repository, but I still get the error that the function geom_parliament() wasn't found. I have run the same code which is on ReadMe. It also says that the package 'ggpol' wasn't found, although I have installed it. Thank you for the attention.

facet_share not working

Dear Frederik, thank you very much for your nice package. I am opening this issue because the example of facet_share from https://erocoar.github.io/ggpol/ is not working anymore. Specifically, I am getting this error:

df <- data.frame(sex = sample(c("M", "F"), 1000, replace = TRUE),
                 age = rnorm(1000, 45, 12))

df$age_bins <- cut(df$age, 15)
df$count <- 1
df <- aggregate(count ~ sex + age_bins, data = df, length)

df_h <- df
df_h$count <- ifelse(df_h$sex == "F", df_h$count * -1, df_h$count)

ggplot(df_h, aes(x = age_bins, y = count, fill = sex)) + 
  geom_bar(stat = "identity") +
  facet_share(~sex, dir = "h", scales = "free", reverse_num = TRUE) + 
  coord_flip()

Error in unit(c(as.numeric(axes$y$left[[1]]$children$axis$widths[[tick_idx]]), :
'list' object cannot be coerced to type 'double'

Do you know how to fix it? I was trying to update with new data a plot that I created with facet_share this time last year, but I cannot due to this facet_share problem.

Thank you in advance for any comment you might provide.

Kind regards,

Guillermo

your pkg with dark bg

Hello,

I decided to try out your pkg and made a rainbow colored ggpol.

when I save this image or use RStudio clipboard it shows white bg edges so i screen captured this

Screen Shot 2021-11-11 at 4 24 10 PM

my initial try was to put ggdark::dark_mode() at the end for a dark plot but that did not work. here is the code i used to make my plot dark, maybe you will find it useful

# install.packages("ggpol")
library(ggpol)

rb = data.frame(
  flag = factor( c('red','orange','yellow',
                   'green','blue','purple')),
  seats = c(200, 46, 92, 80, 153, 69),
  colors = c('red','orange','yellow',
             'green','blue','purple')
)

ggplot(rb) + 
  geom_parliament(aes(seats = seats,
                      fill = flag), 
                  color = "black") + 
  scale_fill_manual(values = rb$colors, 
                    labels = rb$flag) +
  labs(title = "\nParliamentary diagram {ggpol} #PrideFlag")+
  coord_fixed() + 
  theme(
    text = element_text(family = "Rubik"),
    plot.title = element_text(size = 14, 
                              hjust = 0.5
                              ),
    panel.grid.major = element_line(linetype = "blank"),
    panel.grid.minor = element_line(linetype = "blank"),
    legend.text = element_text(colour = "white"),
    legend.title = element_markdown(size = 12,
                                    colour = "white"), 
    panel.background = element_rect(fill = "gray0"),
    plot.background = element_rect(fill = "gray0"),
    legend.background = element_rect(fill = "gray0"),
    legend.position = "bottom", legend.direction = "horizontal",
    axis.text.x = element_blank(),
    axis.text.y = element_blank(),
    axis.ticks = element_blank()
    )

Thanks for the package. : )

Solid fills

Would something like this possible? solid fills instead of points?

52942542-78a35c80-336b-11e9-9091-d470ab1056de

Common limits for both facets when using `facet_share()`

I would like to have a common limit for both facets when using facet_share(). In the example below the largest value on the left is 10 whereas it is 5 on the right. Because the limits are not the same, it looks as though the values are equal.

library(ggplot2)
sex <- rep(c("male", "female"), each = 5)
cat <- rep(LETTERS[1:5], 2)
val <- c(1:5, -(6:10))
df <- tibble::tibble(sex, cat, val)

p <- ggplot(df, aes(cat, val, fill = sex)) +
  geom_col() +
  ggpol::facet_share(vars(sex), scales = "free", reverse_num = TRUE) + 
  coord_flip()
p

image

A naive way to set the limits failed as expected.

p + ylim(0, 10)

image

It would be great to have an option for both facets to have the same limits.

facet_share.R with option: dir="v" returns errors

facet_share.R has a bug which produces the error when dir="v" option is used.

Error in unit(c(axes$x$bottom[[1]]$children$axis$heights[[tick_idx]], :
'list' object cannot be coerced to type 'double'

The heights parameter needs to be defined as:

heights = unit(c(as.numeric(axes$x$bottom[[1]]$children$axis$heights[[tick_idx]]), 1,
as.numeric(axes$x$bottom[[1]]$children$axis$heights[[tick_idx]])),
c("pt", "grobwidth", "pt"),
list(NULL, axes$x$bottom[[1]]$children$axis$grobs[[lab_idx]], NULL))

Installation failed: Command failed (1)

I tried to install it a couple of times and both times it failed installation. I am using R version 3.4 on MacOS

I get the following error:

** R
Error in .install_package_code_files(".", instdir) :
files in '/private/var/folders/w0/zf6n6gbd2kd0jlvsm9hlb6kw0000gn/T/RtmpEZgP7p/devtoolsfc6e722fff86/erocoar-ggpol-5840b1a/R' missing from 'Collate' field:
geom_bartext.R
ERROR: unable to collate and parse R files for package โ€˜ggpolโ€™

  • removing โ€˜/Library/Frameworks/R.framework/Versions/3.4/Resources/library/ggpolโ€™
    Installation failed: Command failed (1)

remove outliers without filtering out

I'd like to remove outliers from a box jitter plot. I tried outlier.color =NA, outlier.alpla=0, and outlier.fill=NA but none of these alone or in comb did not work. Is there a way to remove outliners from the box jitter plot without manipulating the original df in question ?

Thanks.

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.