Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

Distorted line (with non-solid linetype) ggplot on mac

$
0
0

First time poster here. I hope I am doing it correctly. I have had the following issue for a while now and I really want to understand what is going wrong.

I am trying to plot a dashed line with ggplot.

x = c(1:405)
y = c(rep(0,135),seq(1:135),rep(135,135))

ggplot() + geom_line(aes(x, y),linetype = 2, size=1)

However, the dashed line comes out distorted. The lines are not evenly spaced. This happens both in the plot-window in R, and when I save the plot with ggsave. When I change the size of the plot-window the distortion changes, but it occurs usually around x = 100, 200 and/or 300. It is happening both in R and Rstudio. I am using a Mac have everything updated to the newest versions. When my colleague plots the same line in linux he has no issues.

Distorted dashed line

enter image description here

This is the sessionInfo:

R version 3.6.2 (2019-12-12)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Catalina 10.15.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.6/Resources/lib/libRlapack.dylib

Random number generation:
 RNG:     Mersenne-Twister 
 Normal:  Inversion 
 Sample:  Rounding 

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] data.table_1.12.8 gtools_3.8.1      Rcpp_1.0.3        svMisc_1.1.0      cowplot_1.0.0     dplyr_0.8.3       zoo_1.8-6         car_3.0-5         carData_3.0-3    
[10] ggplot2_3.2.1     lmerTest_3.1-1    lme4_1.1-21       Matrix_1.2-18    

loaded via a namespace (and not attached):
 [1] tidyselect_0.2.5    purrr_0.3.3         splines_3.6.2       haven_2.2.0         lattice_0.20-38     colorspace_1.4-1    vctrs_0.2.1         utf8_1.1.4         
 [9] rlang_0.4.2         nloptr_1.2.1        pillar_1.4.2        foreign_0.8-72      glue_1.3.1          withr_2.1.2         readxl_1.3.1        lifecycle_0.1.0    
[17] munsell_0.5.0       gtable_0.3.0        cellranger_1.1.0    zip_2.0.4           labeling_0.3        rio_0.5.16          forcats_0.4.0       curl_4.3           
[25] fansi_0.4.0         scales_1.1.0        backports_1.1.5     abind_1.4-5         farver_2.0.1        hms_0.5.2           digest_0.6.23       stringi_1.4.3      
[33] openxlsx_4.1.4      numDeriv_2016.8-1.1 grid_3.6.2          cli_2.0.0           tools_3.6.2         magrittr_1.5        lazyeval_0.2.2      tibble_2.1.3       
[41] crayon_1.3.4        pkgconfig_2.0.3     zeallot_0.1.0       MASS_7.3-51.4       assertthat_0.2.1    minqa_1.2.4         rstudioapi_0.10     R6_2.4.1           
[49] boot_1.3-23         nlme_3.1-142        compiler_3.6.2    

Does anyone know what could be the problem?


Viewing all articles
Browse latest Browse all 201839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>