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

\n in the axis title causes problem #9

Closed
vzemlys opened this issue Oct 5, 2016 · 5 comments
Closed

\n in the axis title causes problem #9

vzemlys opened this issue Oct 5, 2016 · 5 comments

Comments

@vzemlys
Copy link

@vzemlys vzemlys commented Oct 5, 2016

I've encountered the following weird problem. If there is an "\n" in the begining of the axis title, axis titles disappear altogether from the ggplot.

The code to reproduce:

library(ggplot2)
library(showtext)
showtext.auto()
png("test.png")
ggplot(data=data.frame(x=rnorm(10),y=rnorm(10)),aes(x=x,y=y))+geom_point()+labs(x="\nLong line\nCanother\n(line")
dev.off()

The result is that, the x axis title together with y axis title disappear completely. If \n is removed at the begining, then everything displays perfectly. Also if we do not use showtext the bug does not appear. This bug is fully reproducible on my remote Linux server. However I can only reproduce it on this particular machine. Everything is fine on my local Macbook Pro. Here is the sessionInfo() of that particular Linux server:

R version 3.3.1 (2016-06-21)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Debian GNU/Linux 8 (jessie)

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

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

other attached packages:
[1] showtext_0.4-4     sysfonts_0.5       ggplot2_2.1.0.9001

loaded via a namespace (and not attached):
 [1] labeling_0.3     colorspace_1.2-6 scales_0.4.0     assertthat_0.1  
 [5] lazyeval_0.2.0   plyr_1.8.4       tools_3.3.1      gtable_0.2.0    
 [9] showtextdb_1.0   tibble_1.2       Rcpp_0.12.7      grid_3.3.1      
[13] munsell_0.4.3   

and the devtools::session_info()

Session info -------------------------------------------------------------------
 setting  value                       
 version  R version 3.3.1 (2016-06-21)
 system   x86_64, linux-gnu           
 ui       X11                         
 language (EN)                        
 collate  en_US.UTF-8                 
 tz       <NA>                        
 date     2016-10-05                  

Packages -----------------------------------------------------------------------
 package    * version    date       source                         
 assertthat   0.1        2013-12-06 CRAN (R 3.3.0)                 
 colorspace   1.2-6      2015-03-11 CRAN (R 3.3.0)                 
 devtools     1.12.0     2016-06-24 CRAN (R 3.3.0)                 
 digest       0.6.10     2016-08-02 cran (@0.6.10)                 
 ggplot2    * 2.1.0.9001 2016-10-04 Github (hadley/ggplot2@5a18687)
 gtable       0.2.0      2016-02-26 CRAN (R 3.3.0)                 
 labeling     0.3        2014-08-23 CRAN (R 3.3.0)                 
 lazyeval     0.2.0      2016-06-12 CRAN (R 3.3.0)                 
 memoise      1.0.0      2016-01-29 CRAN (R 3.3.0)                 
 munsell      0.4.3      2016-02-13 CRAN (R 3.3.0)                 
 plyr         1.8.4      2016-06-08 CRAN (R 3.3.0)                 
 Rcpp         0.12.7     2016-09-05 cran (@0.12.7)                 
 scales       0.4.0      2016-02-26 CRAN (R 3.3.0)                 
 showtext   * 0.4-4      2015-10-30 CRAN (R 3.3.1)                 
 showtextdb   1.0        2015-03-10 CRAN (R 3.3.1)                 
 sysfonts   * 0.5        2015-04-27 CRAN (R 3.3.1)                 
 tibble       1.2        2016-08-26 cran (@1.2)                    
 withr        1.0.2      2016-06-20 CRAN (R 3.3.0) 

I was not able to reproduce this on my Mac OS X 10.11.16 running R 3.3.0 with the same versions of ggplot2 and showtext. Here is the relevant devtools::session_info():

Session info -------------------------------------------------------------------
 setting  value                       
 version  R version 3.3.0 (2016-05-03)
 system   x86_64, darwin13.4.0        
 ui       X11                         
 language (EN)                        
 collate  C                           
 tz       Europe/Vilnius              
 date     2016-10-05                  

Packages -----------------------------------------------------------------------
 package    * version    date       source                         
 Rcpp         0.12.7     2016-09-05 cran (@0.12.7)                 
 assertthat   0.1        2013-12-06 CRAN (R 3.3.0)                 
 colorspace   1.2-6      2015-03-11 CRAN (R 3.3.0)                 
 devtools     1.12.0     2016-06-24 CRAN (R 3.3.0)                 
 digest       0.6.10     2016-08-02 cran (@0.6.10)                 
 ggplot2    * 2.1.0.9001 2016-10-05 Github (hadley/ggplot2@5a18687)
 gtable       0.2.0      2016-02-26 CRAN (R 3.3.0)                 
 labeling     0.3        2014-08-23 CRAN (R 3.3.0)                 
 lazyeval     0.2.0      2016-06-12 CRAN (R 3.3.0)                 
 memoise      1.0.0      2016-01-29 CRAN (R 3.3.0)                 
 munsell      0.4.3      2016-02-13 CRAN (R 3.3.0)                 
 plyr         1.8.4      2016-06-08 CRAN (R 3.3.0)                 
 scales       0.4.0      2016-02-26 CRAN (R 3.3.0)                 
 showtext   * 0.4-4      2015-10-30 CRAN (R 3.3.0)                 
 showtextdb   1.0        2015-03-10 CRAN (R 3.3.0)                 
 sysfonts   * 0.5        2015-04-27 CRAN (R 3.3.0)                 
 tibble       1.2        2016-08-26 cran (@1.2)                    
 withr        1.0.2      2016-06-20 CRAN (R 3.3.0)                 
@yixuan
Copy link
Owner

@yixuan yixuan commented Oct 6, 2016

Hi @vzemlys , thanks for the report. However I could not reproduce this issue on my machine either. I suspect that this is due to the system libraries to build showtext, such as freetype and libpng. Could you also report the version of those libraries also?

@vzemlys
Copy link
Author

@vzemlys vzemlys commented Oct 6, 2016

Here it is:

dpkg -l | grep freetype    
ii  libfreetype6:amd64                 2.5.2-3+deb8u1              amd64        FreeType 2 font engine, shared library files
ii  libfreetype6-dev                   2.5.2-3+deb8u1              amd64        FreeType 2 font engine, development files

dpkg -l | grep libpng
ii  libpng12-0:amd64                   1.2.50-2+deb8u2             amd64        PNG library - runtime
ii  libpng12-dev:amd64                 1.2.50-2+deb8u2             amd64        PNG library - development
@yixuan
Copy link
Owner

@yixuan yixuan commented Oct 6, 2016

Now I can reproduce this problem in a Linux server. Will investigate later. Thanks.

@yixuan
Copy link
Owner

@yixuan yixuan commented Oct 13, 2016

Hi @vzemlys, this problem has been fixed on github. I'll submit a new version to CRAN later.

@yixuan
Copy link
Owner

@yixuan yixuan commented Nov 28, 2016

I just realized that I should close this issue, unless you have any other problems.

@yixuan yixuan closed this Nov 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.