-
Notifications
You must be signed in to change notification settings - Fork 25
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
discussion: use roxygen + use new bandwidth estimation (fixes erors caused by lack of variation) + interprete density in device coordinates + deprecate "knn" #23
base: master
Are you sure you want to change the base?
Conversation
replace deprecated stat(density) with after_stat(density)
@@ -13,27 +13,67 @@ count_neighbors_r <- function(x, y, r2, xy) { | |||
}) | |||
} | |||
|
|||
|
|||
#' Wraps the user supplied Geom (typically GeomPoint) to add class "check_aspect_grob" and information about the aspect ratio assumed under which the densities were calculated to the grobs it draws | |||
#' The check is injected by providing an S3 instance to the makeContext generic that is called by grid for each grob at render time (where the actual plot aspect ratio is finally known) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just out of curiosity, does this mean the density gets re-calculated each time the viewer pane in RStudio is resized?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. If you did not use either +theme(aspect.ratio=``)
or +coord_fixed()
, it will just emit a warning every time you resize the pane (unless you adjust it perfectly such that the actual panel aspect ratio is 1)
Hi @jan-glx , The housekeeping stuff makes sense of course, but I have some questions regarding your other commits. It's been a few years since I wrote the original code so I forgot some details that would help me understand what you did 😄 So let me ask some questions to clarify and refresh my memory. Regarding 3d75d67, what's the between using Regarding b18b99f and 9b5e4c7, I do believe the density should be calculated in device coordinates. So the rationale behind your changes makes perfect sense to me, and honestly I thought that's what my implementation was already doing. So I guess you again found some scenario where this is not the case, or my original implementation was buggy. Which one is it? Regarding 50c2e20, @slowkow benchmarked both methods a while ago (https://twitter.com/slowkow/status/1169047484716466176?t=bOaQ_Def4u2qz_9zwystiw&s=19) and found that the original method is faster (for small-ish data sets at least). So I guess it has some advantages. In any case, I want to overhaul the |
Hi @LKremer great to see you finding some time for this nice package, unfortunately I don't have any spare time at the moment and hardly remember how I reached this PR. Let me give a few unverified short comments that might help making use of this work: regarding 3d75d67 : Regarding b18b99f and 9b5e4c7, your dx/dy implementation does achieve that to some extent but only precisely if the aspect ratio is 1 (any maybe also only if there are no transformations and equal expansions). There is no way to fix this completely automatically as the ggplot does not know on what device it will be be plotted at that time. If you resize the plot in Rstudio the aspect ratio changes (and thus the correct densities will be different) but no ggplot function is called during the resize. The easy way to fix this is to always use Regarding 50c2e20 : yes knn is |
#' `adjust = 0.5` means use half of the default. Other arguments may be | ||
#' aesthetics, used to set an aesthetic to a fixed value, like `shape = | ||
#' 17` or `size = 3`. They may also be parameters to the paired geom/stat. | ||
#' @param na.rm If `FALSE`, the default, missing values are removed with a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing @param
for method
and aspect.ratio
arguments
I have made a few changes in my fork that cover my needs and would be happy to prepare issues / PRs for the parts you think are a good idea/solution.
roxygen
(16d334d, d641221)testthat
( 8f0a857 , d17e5cc )