-
-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Blank Plot Output when using "geom_xspline" in ggalt package #60
Comments
I made a few changes to the new GeomXSpline <- ggplot2::ggproto("GeomXSpline", ggplot2::Geom,
required_aes = c("x", "y"),
default_aes = ggplot2::aes(colour = "black",
size = 0.5,
linetype = 1,
alpha = 1,
spline_shape=-1,
open=T),
draw_key = ggplot2::draw_key_smooth, # controls what is drawn in legend
draw_group = function(data, panel_params, coord) {
n <- nrow(data)
if (n <= 2) return(grid::nullGrob())
coords <- coord$transform(data, panel_params)
first_row <- coords[1, , drop = FALSE]
grid::xsplineGrob(
coords$x, coords$y,
shape = coords$spline_shape,
open = coords$open[1],
gp = grid::gpar(col = first_row$colour,
lwd = first_row$size * .pt,
alpha = first_row$alpha,
lty = first_row$linetype)
)
}
)
geom_xspline <- function(mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
spline_shape = -1,
open = T,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE,
...) {
layer(
geom = GeomXSpline,
mapping = mapping,
data = data,
stat = stat,
position = position,
show.legend = show.legend,
inherit.aes = inherit.aes,
params = list(spline_shape = spline_shape,
open = open,
na.rm = na.rm,
...)
)
} |
I recently was trying
geom_xspline
from theggalt
to replace an existinggeom_line
in my ggplot object. When usingggarrange
andgeom_xspline
, a blank screen was output and no other plots could be passed through RStudio until the session was restarted. I left a similar post on theggpubr
GitHub page; however, I believe the source of the bug resides inggalt
.Working Code w/o
geom_xspline
Code using
geom_xspline
(no RStudio preview panel output)Based upon this stack overflow page, the output from
ggarrange
can still be saved, even though it doesn't display in RStudio.There is also a proposed solution to address the issue by making adjustments to
geom_xspline2
. I am not sure if this is a feasible solution to add toggalt
on CRAN but it appears to work withggarrange
in this rough example:The text was updated successfully, but these errors were encountered: