daattali/ggExtra

Don't plot empty bins?

dstern opened this issue · 6 comments

Dean
Love the marginal histogram plots.
I am plotting data with sparse distributions and would like to plot only bins that contain data. Here's an example
image
I am surprised it plots for empty bins, because just plotting with geom_histogram gives the histogram with empty bins not plotted.
image
Is there an easy, hidden way to not plot bins with missing data in marginal histograms ?
Thanks, David

Hi David, I'm not quite sure where you see a problem there. Please provide sample input and code to reproduce the issue, and highlight where you see a problem. I'm not sure where in the marginal plots you see empty bins plotted that are not plotted in the geom_histogram, can you please clarify

Perhaps I was not clear.
The top (blue) histogram contains the same data as the bottom (gray) histogram. In the blue histogram, bins with 0 counts are plotted as a solid line. I would like to remove this line so that only bins with values are visible. Perhaps this line is not technically a bin? In any case, I would love to be able to remove it.

Oh I see what you mean. That bottom line is not empty bins, it's just a border line that is always drawn. I don't remember the exact parameters but I don't think you can remove that line without digging into the source code

Yeah, not possible to remove line without changing source code.

Thanks. I'll dig into the code and let you know if I come with anything useful.

You'll definitely be able to remove it by modifying the source code, it's just one (of the many!) theme options that are set. I'm closing this issue because this is not something that is going to change in the package. Feel free to ask for help if you're unable to find the exact option that sets this line