dbplot icon indicating copy to clipboard operation
dbplot copied to clipboard

How to color bars in histogram?

Open EarlGlynn opened this issue 6 years ago • 4 comments

In the "Calculation functions" section you show a histogram with a scale on the left and a color legend on the right. This color legend is not needed and is not conventional with histograms (IMHO). The color legend doesn't add any information that's not in the scale at the left.

But how can I change the bars in the histogram to some constant color? Why doesn't something like fill="red" work?

EarlGlynn avatar Mar 22 '18 20:03 EarlGlynn

Hi, thanks for your feedback! Not sure why is not working for you. The only thing I can think off is that the fill argument needs to be "outside" the aes() function, for example: geom_col(aes(arr_delay, count), fill = "red"). Here is a full example that worked on my machine:

flights %>%
  filter(arr_delay < 100 , arr_delay > -50) %>%
  db_compute_bins(arr_delay) %>%
  ggplot() +
  geom_col(aes(arr_delay, count), fill = "red")

edgararuiz-zz avatar Mar 23 '18 13:03 edgararuiz-zz

You were right. I had tried "fill" in the wrong place. BTW, is there any parameter to, or some sort of modification, that allows changing the default color of a histogram using dbplot_histogram directly?

dbplot functions have worked well for me on tables of ~400 million records so far. Hope to see if it works on several billion records in the near future. Thanks for writing dbplot!

EarlGlynn avatar Mar 23 '18 18:03 EarlGlynn

That's great to hear! Thank you.

Let me see what I can do regarding additional parameters for dbplot_histogram(). It may be that we could just pass additional arguments passed to dbplot_histogram() directly to the geom, the only challenge would be to decide if we're to have a way to know if the parameter should go inside or outside aes()

edgararuiz-zz avatar Mar 23 '18 18:03 edgararuiz-zz

Maybe just a fill_manual or color_manual argument inside dbplot_? To emphasize that the parameter is outside aes()?

filipwastberg avatar Sep 25 '19 14:09 filipwastberg