Skip to content

Let ggplot handle histogran binning. Fix #198 #200

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

Merged
merged 7 commits into from
Apr 16, 2015
Merged

Conversation

cpsievert
Copy link
Collaborator

This pull request started out as a fix for #198, but I quickly realized the implementation of geom_bar()/geom_histogram() was suboptimal for a couple reasons

  1. The binning for histograms was done by plotly. Not only is this default binning different, but that also means a number of arguments in stat_bin are ignored. If the goal is to have a correct mapping from ggplot2 to plotly, we should let ggplot2 handle the binning, then use a type="bar" and bargap=0.
  2. This thinking lead to false warnings. For example, ggplot(mtcars, aes(factor(vs)))+geom_bar() would throw a warning, but it shouldn’t.

@cpsievert
Copy link
Collaborator Author

This is still a work in progress, but the main idea is there...

@cpsievert
Copy link
Collaborator Author

@tdhock any idea why the home page for this commit says "could not download .png", but the individual pages appear to be working?

@tdhock
Copy link
Contributor

tdhock commented Apr 13, 2015

the "could not download .png" happens when the plotly server returns an error instead of a png when building the test table.

https://github.com/ropensci/plotly-test-table/blob/gh-pages/table.R#L390-L398

Usually you can just wait a while and re-build the test table when the server gets working again. I guess that is what you did, since I did not see any "could not download" errors on http://ropensci.github.io/plotly-test-table/tables/b938fdab8311104f2dfe61cc4bf21798a0e48810/index.html

@chriddyp
Copy link
Member

Looking good! I agree that this is the right approach, it'll be a much smaller request for very large data-sets, too.

@cpsievert
Copy link
Collaborator Author

I'm ready to merge now. Please review @tdhock @chriddyp @mkcor

(note you can also map fill for histograms now)

http://ropensci.github.io/plotly-test-table/tables/ce61432fb22993d0597abe299bc79e4b44029de5/histogram-fill.html

@chriddyp
Copy link
Member

Looks great! 💃 by me, but @tdhock might want to do a more thorough code review

@tdhock
Copy link
Contributor

tdhock commented Apr 13, 2015

I'll code review tomorrow.

@@ -242,6 +242,41 @@ gg2list <- function(p){
if (!all(barmodes == barmodes[1]))
warning(paste0("You have multiple barcharts or histograms with different positions; ",
"Plotly's layout barmode will be '", layout$barmode, "'."))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

want to add a test with expect_warning?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This warning existed before and I'm not sure of an example where it's applicable, but it might be worth keeping in case we run across an edge case...

@tdhock
Copy link
Contributor

tdhock commented Apr 14, 2015

other than that everything looks fine, including the visual tests.

+1

cpsievert added a commit that referenced this pull request Apr 16, 2015
Let ggplot handle histogran binning. Fix #198
@cpsievert cpsievert merged commit d958976 into master Apr 16, 2015
@cpsievert cpsievert deleted the carson-bars branch April 16, 2015 01:58
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

Successfully merging this pull request may close these issues.

3 participants