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

geom_text_repel() not working with coord_polar() #56

Closed
jakeyeung opened this issue Nov 7, 2016 · 3 comments
Closed

geom_text_repel() not working with coord_polar() #56

jakeyeung opened this issue Nov 7, 2016 · 3 comments
Labels

Comments

@jakeyeung
Copy link

jakeyeung commented Nov 7, 2016

Hi slowkow, nice package by the way. I think my code was working before (about one month ago) but recently I got some issues.

I find that geom_text_repel() does not work when I use coord_polar().

Here is an example:

set.seed(0)
test <- data.frame(
  R = runif(n = 15, min = 0.5, max = 1), 
  phi = runif(n = 15, min = 0, max = 24),
  Label = sample(x = letters, 15, replace = FALSE)
)

# works
ggplot(test, aes(x = R, y = phi, label = Label)) +
  coord_polar(theta = "y") +
  geom_text() +
  expand_limits(x = 0) +
  scale_y_continuous(limits = c(0, 24), breaks = seq(6, 24, 6))

# doesnt work:
# Error in if (text_box[1] <= point_pos[1] && point_pos[1] <= text_box[3] &&  : 
# missing value where TRUE/FALSE needed
ggplot(test, aes(x = R, y = phi, label = Label)) +
  coord_polar(theta = "y") + geom_text_repel() +
  expand_limits(x = 0) +
  scale_y_continuous(limits = c(0, 24), breaks = seq(6, 24, 6))

The example code should look like this:

plot_zoom_png-26

My sessionInfo() is:

> R version 3.3.1 (2016-06-21)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)
locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8      
 [8] LC_NAME=C                  LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
attached base packages:
[1] grid      stats     graphics  grDevices utils     datasets  methods   base     
other attached packages:
[1] ggrepel_0.6.3  glmnet_2.0-5   foreach_1.4.3  Matrix_1.2-7.1 ggplot2_2.1.0  dplyr_0.5.0    reshape2_1.4.2 hash_2.2.6    
loaded via a namespace (and not attached):
 [1] Rcpp_0.12.7          AnnotationDbi_1.28.2 magrittr_1.5         BiocGenerics_0.12.1  IRanges_2.0.1        munsell_0.4.3        lattice_0.20-34      colorspace_1.2-7     R6_2.2.0            
[10] stringr_1.1.0        GenomeInfoDb_1.2.5   plyr_1.8.4           tools_3.3.1          parallel_3.3.1       Biobase_2.26.0       gtable_0.2.0         DBI_0.5-1            iterators_1.0.8     
[19] lazyeval_0.2.0       assertthat_0.1       tibble_1.2           codetools_0.2-15     S4Vectors_0.4.0      RSQLite_1.0.0        labeling_0.3         stringi_1.1.2        scales_0.4.0        
[28] stats4_3.3.1         XML_3.98-1.4    
@slowkow
Copy link
Owner

slowkow commented Nov 7, 2016

Jake, thanks for the issue report.

Could I ask you to please display the figures in your issue so we can see
how it looks?

I hadn't considered polar coordinates when developing this package.

I would happily review a pull request that implements this feature.

On Nov 7, 2016 5:42 AM, "Jake Yeung" notifications@github.com wrote:

Hi,

I find that geom_text_repel() does not work when I use coord_polar().

Here is an example code:
`
set.seed(0)
test <- data.frame(R = runif(n = 15, min = 0.5, max = 1),
phi = runif(n = 15, min = 0, max = 24),
Label = sample(x = letters, 15, replace = FALSE))
works fine

ggplot(test, aes(x = R, y = phi, label = Label)) + coord_polar(theta =
"y") + geom_text() + expand_limits(x = 0) + scale_y_continuous(limits =
c(0, 24), breaks = seq(6, 24, 6))
doesnt work Error in if (text_box[1] <= point_pos[1] && point_pos[1] <=
text_box[3] && : missing value where TRUE/FALSE needed

ggplot(test, aes(x = R, y = phi, label = Label)) + coord_polar(theta =
"y") + geom_text_repel() + expand_limits(x = 0) + scale_y_continuous(limits
= c(0, 24), breaks = seq(6, 24, 6))
`

My infoSession() is:

R version 3.3.1 (2016-06-21)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8
LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
LC_PAPER=en_US.UTF-8
[8] LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8
LC_IDENTIFICATION=C

attached base packages:
[1] grid stats graphics grDevices utils datasets methods base

other attached packages:
[1] ggrepel_0.6.3 glmnet_2.0-5 foreach_1.4.3 Matrix_1.2-7.1 ggplot2_2.1.0
dplyr_0.5.0 reshape2_1.4.2 hash_2.2.6

loaded via a namespace (and not attached):
[1] Rcpp_0.12.7 AnnotationDbi_1.28.2 magrittr_1.5 BiocGenerics_0.12.1
IRanges_2.0.1 munsell_0.4.3 lattice_0.20-34 colorspace_1.2-7 R6_2.2.0
[10] stringr_1.1.0 GenomeInfoDb_1.2.5 plyr_1.8.4 tools_3.3.1
parallel_3.3.1 Biobase_2.26.0 gtable_0.2.0 DBI_0.5-1 iterators_1.0.8
[19] lazyeval_0.2.0 assertthat_0.1 tibble_1.2 codetools_0.2-15
S4Vectors_0.4.0 RSQLite_1.0.0 labeling_0.3 stringi_1.1.2 scales_0.4.0
[28] stats4_3.3.1 XML_3.98-1.4


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#56, or mute the thread
https://github.com/notifications/unsubscribe-auth/AAMzMqa1l8KTwj1dE--Ez5KyiqOShgNeks5q7wCHgaJpZM4KrEO1
.

@jakeyeung
Copy link
Author

jakeyeung commented Nov 7, 2016

Hi Slowkow, thanks for the quick response.

The thing is, the package actually worked previously, here is an example of geom_text_repel() working (generated last month):

example

EDIT:
Actually, an older version of ggrepel solves this issue, specifically version 0.6.1.

Running the plotting script in version 0.6.1 gives the correct output:

works

I am not familiar with how makeContent.textrepelgrob() is used, but I noticed in version 0.6.3, the variable x$x and x$y outputs NaN whereas in version 0.6.1 it outputs finite numbers.

Jake

@slowkow slowkow added the bug label Nov 7, 2016
slowkow added a commit that referenced this issue Nov 8, 2016
@slowkow
Copy link
Owner

slowkow commented Nov 8, 2016

@jakeyeung Could I ask you to please reopen this issue if version 0.6.4 does not work for you?

@slowkow slowkow closed this as completed Nov 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants