J.Z.
J.Z.

Reputation: 435

Plot Line Types in R

Update:

This has been confirmed as a current bug on Apple OS as of Feb 28, 2022.


Update:

Below is my sessionInfo. I have tried to restart my RStudio and tried dev.off(), but neither works. I am still getting the odd dashed line.

I have tried the codes on R (not RStudio) and the dashed line is still wrong.

> sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Monterey 12.2.1

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.1/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     

loaded via a namespace (and not attached):
[1] compiler_4.1.2 tools_4.1.2   

The following codes will produce Plot 1.

zeta.ppt <- function(v){
  ppt=function(i){
    result <- numeric(length(i))
    for (j in i){
      if (j < 11) {result[j] <- (11-j)/110}
      else {result[j] <- 3/pi^2/(j-10)^2}
    }
    result
  }
  p <- ppt(1:10000)
  printout <- numeric(length(v))
  for (k in 1:length(v)) {
    printout[k] <- sum(p*(1-p)^v[k])
  }
  printout
}
zeta.sept <- function(v){
  sept=function(i){
    result <- numeric(length(i))
    for (j in i){
      if (j < 11) {result[j] <- (11-j)/110}
      else {result[j] <- 0.5/1.670407*exp(-sqrt(j-10))}
    }
    result
  }
  p <- sept(1:10000)
  printout <- numeric(length(v))
  for (k in 1:length(v)) {
    printout[k] <- sum(p*(1-p)^v[k])
  }
  printout
}
tau.ppt <- function(v){
  v*zeta.ppt(v)
}
tau.sept <- function(v){
  v*zeta.sept(v)
}
plot(log(tau.ppt(1:20000))~log(1:20000), xlim = c(0,10), ylim=c(0, 5), axes = F, ylab = "", xlab = "", type = "l")
lines(log(tau.sept(1:20000))~log(1:20000), lty = 2, type = "l")
box()

Plot 1

If you look at the dashed line, it is not evenly separated in its right-hand side portion. How can I make it an evenly spaced dashed line like Plot 2?

Plot 2

Thanks!

Upvotes: 1

Views: 170

Answers (1)

JAdel
JAdel

Reputation: 1616

I have plot it in RStudio and the line is separated (Author asked to show my image). You could also try to run dev.off() before you plot your image.

My RStudio version:

R version 4.1.2 (2021-11-01)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22000)

enter image description here

Upvotes: 1

Related Questions