Skip to content
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

dbplot_histogram resulting in empty plots + proper histograms #31

Open
RonaldVisser opened this issue Apr 28, 2020 · 3 comments
Open

dbplot_histogram resulting in empty plots + proper histograms #31

RonaldVisser opened this issue Apr 28, 2020 · 3 comments

Comments

@RonaldVisser
Copy link

I enjoy using this library, but recently the histograms were not working as should. There were no bars for numeric values, only an empty graph. For integers there was no problem...

Solution: change line 92 in https://github.com/edgararuiz/dbplot/blob/master/R/histogram.R

92 (old) geom_col(aes(x, count)) +
92 (new) geom_col(aes(x, count), orientation="x", width = binwidth) +

This works as a charm when binwidths are known and it produces proper histograms at the same time, since there should be no gap between bars in a histogram!
Although this does not work when the binwidth is not set, maybe the binwidth calculation from (https://github.com/edgararuiz/dbplot/blob/master/R/dbbin.R) could be included somehow?

Thanks in advance!

@leungi
Copy link

leungi commented Jun 1, 2020

Thanks for opening this @RonaldVisser; same thoughts here. Hence, created PR #32.

Since dbplot_histogram()already usedb_compute_binsinternally, it includes the logic fromdb_binto auto-compute binwidth when it's leftNULL`.

@jarodmeng
Copy link

@leungi A more general (and backwards compatible) solution is to bubble up the "orientation" argument to the "dbplot_histogram" function with a default value of NA. In this way, users who call the dbplot_histogram() function without the "orientation" argument will get exactly the same behavior, but users who prefer to set the orientation (most probably because the auto-detection of orientation fails) can set it in "dbplot_histogram" and it will get passed to the "geom_col()" call.

@leungi
Copy link

leungi commented Sep 11, 2020

@jarodmeng : thanks for feedback; let's see how the pkg maintainers (e.g., @edgararuiz ) respond to this issue.

I can update my PR #32 as needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants