-
Notifications
You must be signed in to change notification settings - Fork 16
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
do not special case 1 group #41
base: master
Are you sure you want to change the base?
Conversation
Yep! Thanks for the example plot as well. (it's great that you discovered this, definitely looks out of place for a single label with large text)
For sure, I'll add it when I'm making the test cases 👍 |
@tdhock For e.g. this PR is passing the check because the commits are made by you (please merge both!) |
before merging this PR can you please push the test cases I described above? |
okay sure! Thanks for adding me as a collaborator, yep I'll drop the fork now! |
Hi @tdhock I would like to get the y-coordinate of the topmost side of the drawn polygon, which I'd like to compare with the plot's topmost point or maximum y-value (which should be another grob, probably a polyline) - the former should exceed the later. I'm aware that currently it is not possible to work on the polygon grob and the text contained within (until #44 is done with) as because our dlgrob cannot be forced: But still I am curious - like in general, we can edit the original properties of a drawn grob using Also asking this because it is related to the way I thought to implement this test case - I would go with the code you supplied and use an I drafted this, but I don't think this is what you had in mind: library(testthat)
context("Single label group with large (multiline) text")
test_that("Top of the drawn polygon/text grobs (dlgrob) should be below the plotting region.", {
df <- data.frame(i=1:10, label="more
than
one
line
really
a
lot")
library(ggplot2)
gg <- ggplot(df, aes(i, i, color=label)) + geom_line()
directlabels::direct.label(gg, "right.polygons")
# Single group: (not considered for collisions in qp.labels previously)
expect_equal(length(unique(df$label)), 1)
# Multiline:
expect_gt(nchar(gsub("[^\n]+", "", df$label[1])), 1)
}) I wonder what I should test for in this case? |
@tdhock re-pinging here in case the above comment didn't pop up in your mail |
yes there should be some way to query the x,y position of a drawn grid grob, I don't remember how right now, please ask @pmur002 who is author of grid package. |
51adde8
to
10e243b
Compare
hi @Anirban166 this PR contains a fix for the following example:
When you run this code on master, the label text will be unreadable (going off the top of the plotting region).
Can you please add a test case for this sometime before the end of the summer?
The test case should basically say, the top of the polygon / text grobs should be at or below the top of the plotting region.
Does that make sense?