-
Notifications
You must be signed in to change notification settings - Fork 0
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
plotting binned plots with non- binned plots #3
Comments
That's a good question, and frankly, I have no idea. It isn't something I ever set out to support. I wonder if it would be possible to achieve what you want by using the (currently internal) But probably the best solution is to make the plots directly in require(linbin)
require(ggplot2)
# Prepare data
e <- simple
bins <- seq_events(event_range(e), length.out = c(16, 4, 2))
binned_wide <- sample_events(e, bins, list(sum, c('x', 'y'), na.rm = TRUE))
binned_long <- tidyr::pivot_longer(
binned_wide, cols = c('x', 'y'), names_to = 'variable'
)
# Plot with ggplot2
ggplot(binned_long, aes(xmin = from, xmax = to, ymin = 0, ymax = value)) +
geom_rect() +
facet_grid(variable ~ group) |
Thank you so much for your response, Dr. Welty.
When I attempted to plot using the plot_events_simple I got this error
message : Error: 'plot_events_single' is not an exported object from
'namespace:linbin'.
Is there something else required other than library (libin)?
I would also like to adjust the ylim for the individual plots per bin
size. Is it possible to do this within the plot_events_simple
function? Or would this be best to do within ggplot.
…On Sat, Apr 1, 2023 at 2:07 AM Ethan Welty ***@***.***> wrote:
That's a good question, and frankly, I have no idea. It isn't something I ever set out to support. I wonder if it would be possible to achieve what you want by using the (currently internal) plot_events_single function:
https://github.com/ezwelty/linbin/blob/3adf8ecdf583ed7c91b086cf6ac9ab2dbcca71aa/R/plot_events.R#LL132-L132C19
But probably the best solution is to make the plots directly in ggplot2 with geom_rect. Here is an example:
require(linbin)
require(ggplot2)
# Prepare data
e <- simple
bins <- seq_events(event_range(e), length.out = c(16, 4, 2))
binned_wide <- sample_events(e, bins, list(sum, c('x', 'y'), na.rm = TRUE))
binned_long <- tidyr::pivot_longer(
binned_wide, cols = c('x', 'y'), names_to = 'variable'
)
# Plot with ggplot2
ggplot(binned_long, aes(xmin = from, xmax = to, ymin = 0, ymax = value)) +
geom_rect() +
facet_grid(variable ~ group)
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
That is what I meant when I wrote that I've just now updated the code on GitHub to make it possible for users to call install.packages("devtools") # if needed
devtools::install_github("ezwelty/linbin")
As you probably saw, require(linbin)
require(ggplot2)
# Prepare data
e <- simple
bins <- seq_events(event_range(e), length.out = c(16, 4, 2))
binned_wide <- sample_events(e, bins, list(sum, c('x', 'y'), na.rm = TRUE))
binned_long <- tidyr::pivot_longer(
binned_wide, cols = c('x', 'y'), names_to = 'variable'
)
# Plot with ggplot2
ggplot(binned_long, aes(xmin = from, xmax = to, ymin = 0, ymax = value)) +
geom_rect() +
facet_grid(variable ~ group, scales='free_y') |
Is there a function within the linbin package that allows for the generation of non-binned plots aligned with binned plots within the plotted output?
I thought I could work around by making an object out of the linbin output and then plotting in ggplot, but converting the linbin plot out ouput into a GROB seems to have distorted the bin size in the image.
The text was updated successfully, but these errors were encountered: