erocoar / ggpol Goto Github PK
View Code? Open in Web Editor NEW๐ Parliament diagrams and more for ggplot2
Home Page: https://erocoar.github.io/ggpol/
License: Other
๐ Parliament diagrams and more for ggplot2
Home Page: https://erocoar.github.io/ggpol/
License: Other
Hi Developers.
Is there any chance to support box with dots as full box plot, instead of just half box. An example of style as below, a plot from poltly.
boxplot with dots side by side
Thank you very much for this great work.
Best regards
Wallace
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)
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
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!
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.
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
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
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. : )
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
A naive way to set the limits failed as expected.
p + ylim(0, 10)
It would be great to have an option for both facets to have the same limits.
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))
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โ
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.