Skip to content
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

Make the segment the same color as the text #29

Merged
merged 1 commit into from Mar 15, 2016

Conversation

jiho
Copy link
Contributor

@jiho jiho commented Mar 14, 2016

Instead of setting segment.color to a mid-level grey, make it a bit
transparent and color it according to the color of the text. By default
the text is black and the half-transparent segment therefore still
appears grey.

When the text itself is made transparent, the transparency of the text
and of the segment are combined (multiplied).

Another possibility would be to declare two new mappable aesthetics:
segment.color and segment.alpha, and let the user do the mapping (i.e.
geom_text_repel(color=x, segment.color=x)) which would allow to color
the text and segment separately. But I find it quite cumbersome for a
small gain in versatility.

@jiho
Copy link
Contributor Author

jiho commented Mar 14, 2016

NB: this is likely to conflict with my other pull-request (#28) but I thought it best to keep them separate.

Let me know if/when you integrate the other one and I'll rebase this one on the new code.

@jiho
Copy link
Contributor Author

jiho commented Mar 14, 2016

And the demo

library("ggplot2")
library("ggrepel")

set.seed(1)
n <- 10
d <- data.frame(x=runif(n), lab=letters[1:n])

ggplot(d) + geom_text(aes(x=x, y=x, label=lab), color="red")
ggplot(d) + geom_text_repel(aes(x=x, y=x, label=lab), color="red")

ggplot(d) + geom_text(aes(x=x, y=x, label=lab, color=lab))
ggplot(d) + geom_text_repel(aes(x=x, y=x, label=lab, color=lab))

@jiho jiho mentioned this pull request Mar 14, 2016
Instead of setting segment.color to a mid-level grey, make it a bit
transparent and color it according to the color of the text. By default
the text is black and the half-transparent segment therefore still
appears grey.

When the text itself is made transparent, the transparency of the text
and of the segment are combined (multiplied).

Another possibility would be to declare two new *mappable* aesthetics:
segment.color and segment.alpha, and let the user do the mapping (i.e.
geom_text_repel(color=x, segment.color=x)) which would allow to color
the text and segment separately. But I find it quite cumbersome for a
small gain in versatility.
@jiho
Copy link
Contributor Author

jiho commented Mar 15, 2016

I've rebased on master and squashed into one commit make it easier for you to merge if you wish.

@slowkow
Copy link
Owner

slowkow commented Mar 15, 2016

Thank you! I'll consider merging this pull request soon.

slowkow added a commit that referenced this pull request Mar 15, 2016
Make the segment the same color as the text
@slowkow slowkow merged commit 847b714 into slowkow:master Mar 15, 2016
@slowkow
Copy link
Owner

slowkow commented Mar 15, 2016

Thanks again for the pull request! I appreciate it.

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.

None yet

2 participants