slowkow/ggrepel
View on GitHubexcessive legend size causes "Viewport has zero dimension(s)" error
Open
#113 opened on Aug 10, 2018
duplicatehelp wanted
Description
Summary
When the legend is too large and ggrepel is used, the following obtuse error text is produced:
Error in grid.Call(C_convert, x, as.integer(whatfrom), as.integer(whatto), : Viewport has zero dimension(s)
Minimal code example
Here is the minimum amount of code needed to demonstrate the issue:
library(ggplot2)
library(ggrepel)
library(ggplot2movies)
ggplot(movies[1:300,], aes(y = year, x = length, color = factor(title))) +
geom_point() +
geom_text_repel(aes(label = title))
Suggestions
Improve the wording of the error message to indicate that the legend is too large.
A legend this large is useless, and hiding it fixes the problem.
library(ggplot2movies)
ggplot(movies[1:300,], aes(y = year, x = length, color = factor(title))) +
geom_point() +
geom_text_repel(aes(label = title)) +
theme(legend.position="none")
Version information
Here is the output from sessionInfo() in my R session:
R version 3.5.0 (2018-04-23)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.2
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] ggrepel_0.8.0 ggplot2_3.0.0 ggplot2movies_0.0.1 lmerTest_3.0-1 lme4_1.1-17
[6] Matrix_1.2-14
loaded via a namespace (and not attached):
[1] Rcpp_0.12.17 compiler_3.5.0 pillar_1.2.3 nloptr_1.0.4 plyr_1.8.4
[6] bindr_0.1.1 tools_3.5.0 digest_0.6.15 tibble_1.4.2 gtable_0.2.0
[11] nlme_3.1-137 lattice_0.20-35 pkgconfig_2.0.1 rlang_0.2.1 yaml_2.1.19
[16] mvtnorm_1.0-8 bindrcpp_0.2.2 coda_0.19-1 withr_2.1.2 dplyr_0.7.5
[21] lsmeans_2.27-62 tidyselect_0.2.4 grid_3.5.0 glue_1.2.0 R6_2.2.2
[26] survival_2.41-3 multcomp_1.4-8 TH.data_1.0-8 minqa_1.2.4 purrr_0.2.5
[31] magrittr_1.5 scales_0.5.0 codetools_0.2-15 MASS_7.3-49 splines_3.5.0
[36] assertthat_0.2.0 xtable_1.8-2 colorspace_1.3-2 numDeriv_2016.8-1 labeling_0.3
[41] sandwich_2.4-0 estimability_1.3 lazyeval_0.2.1 munsell_0.5.0 zoo_1.8-2