-
Notifications
You must be signed in to change notification settings - Fork 37
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
Panel backgrounds #84
Conversation
legend entry order
Thanks for contributing this great code and tests Kevin. Yes it makes sense to merge this branch without implementing the panel.margin feature. However I ran the test suite and saw the following visual regression (in both firefox and chrome) The top facet labels are cutoff (hard to see in "Years" but the top of the F and the dot on the i are clearly missing in "Fertility rate"). Can you please add a test that fails in test-widerect.R? And then can you please fix that bug? |
…ented in the panel_margins branch
…anel_margins branch
Thanks for catching that. It originated a couple of days ago when I was working on panel margins. I've removed it, I'd prefer to add the test when I start working on the panel margins. Because that is what cause the issue, I think it'd be more consistent to put it there. |
if(is.null(x)) { | ||
TRUE | ||
} else { | ||
(grepl("#", x) & nchar(x)==7) |
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.
Maybe we could change this line to grepl("^#[0-9A-Za-z]{6, 8}$", x)
?
The value section on the help page for rgb()
says:
A character vector with elements of 7 or 9 characters, "#" followed by the red, blue, green and optionally alpha values in hexadecimal (after rescaling to 0 ... 255).
cc @tdhock
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.
+1
@kferris10 can't wait to merge this (looks great)!! It's a huge improvement especially for facetted plots that share an axis. I found it a bit surprising that minor grid lines are drawn over major ones. Is that intentional (is that how ggplot2 does it)? I wrote a test to check the number of minor grid lines, but feel free to modify it if that behavior is to be expected. |
It looks like that's just how ggplot2 does it. Check out the major vs minor
I thought that I was drawing the major lines on top of the minor ones. Is that correct? |
I tried implementing a test for the unreadable strip labels but it seems complicated. How to tell if the svg I tried adding the code below to test-facet-trivial.R: test_that("top strip labels are not cut off", {
viz <-
list(Sk=gg+facet_grid(Species ~ kingdom))
info <- animint2HTML(viz)
strip.rect <- remDr$executeScript('return document.getElementById("topStrip").firstChild.getBoundingClientRect()')
svg.rect <- remDr$executeScript('return document.getElementById("Sk").getBoundingClientRect()')
}) |
@kferris10 I'm not positive, but from these examples, it appears ggplot2 doesn't draw the minor grid lines where the major ones are (I think prefer that behavior anyway so we don't clutter up the DOM) qplot(Sepal.Length, Sepal.Width, data = iris) + theme( panel.grid.minor = element_line("blue")) qplot(Sepal.Length, Sepal.Width, data = iris) + theme(panel.grid.major = element_line("red"), panel.grid.minor = element_line("blue")) |
I agree with Carson. The less DOM elements to create, the faster the On Tue, Jun 16, 2015 at 10:42 AM, Carson notifications@github.com wrote:
|
@tdhock What about this instead? For this check, we just need to make sure that the text is pushed down more than the font size, right?
|
in theory your argument makes sense Kevin. However in practice on my firefox browser the default translate value of 7.25 cuts of the 11px text: but a value of 8 (less than 11px) is sufficient for a strip label that is not cut off: or am I missing something? in cases like this where the test is not straightforward to write, I prefer to just not write a test (avoid false test failures in the future). by the way the code i used was test_that("top strip labels are not cut off", {
miris <- iris
miris$kingdom <- "plANtAEgjiq,!?"
gg <- ggplot()+
geom_point(aes(Petal.Length, Petal.Width),
data=miris)
viz <-
list(Sk=gg+facet_grid(Species ~ kingdom))
info <- animint2HTML(viz)
strip.rect <- remDr$executeScript('return document.getElementById("topStrip").firstChild.getBoundingClientRect()')
svg.rect <- remDr$executeScript('return document.getElementById("Sk").getBoundingClientRect()')
}) |
tests pass on my computer with firefox. +1 go ahead and merge when you like. |
Great, this also has my +1, make sure you update the version in the DESCRIPTION and the NEWS before (or after) merging @kferris10. It'd also be awesome if you could re-build the tutorial to reflect the new theming defaults! |
Not a problem. Are there any other visualizations that should be rebuilt? Also, should I just bump the version to today's date? |
Just the tutorial is fine for now. And yea, use today's date. |
Great, this last commit should take care of that. This means that we can also merge #68 as well, right? |
Cool, go ahead and merge this. After you merge this into master, you might have conflicts when you pull these changes into #68 (waiting to update the version and NEWS helps in this regard). Are you familiar with resolving merge conflicts? If it is a big conflict, sometime I do |
Just found a bug when compiling the animint tutorial. Does it make the most sense to push the fix to this branch or to create a new one? |
can you please first write a test that fails for the viz with the bug? after that I would suggest pushing the changes to a new branch and making a new PR. |
Already done :) |
I've updated the tutorial. @srvanderplas could you take a quick look at it when you get a chance? Three things in particular:
I'll push to this repository once we get this stuff figured out |
Moved from #78
In addition to drawing background rectangles, I amended the linetype test because the background rectangles were interfering with this test. If somebody could confirm that this makes sense, that would be great.
I've drawn the major grid lines and will get to the minor ones as soon as possible