1

Here's the data I am working with.

https://www.dropbox.com/s/dn0dom094epuj2k/test.dat?dl=0

I am simply reading this data in and plotting it:

plot(x=phases, y=mag.lambdas, main=paste("Set D Light Curve",sep=" "), type = "l", pch=3, col="purple",
           xlab=expression("Phase"), ylab=expression("Absolute Magnitude (mags)"), cex.main=1.60, cex.lab=1.50, ceb.axis=1.80)

Yet, when I do so, I get a straight line from the first point to the last point.

enter image description here

How do I get rid of this line?

Woj
  • 449
  • 1
  • 5
  • 15
  • Please check this [question](https://stackoverflow.com/questions/54619283/how-do-i-get-rid-of-the-straight-line-from-the-first-and-last-point). – Artur_Indio Jul 10 '21 at 03:01
  • Your data are not in order. Values of `phases` less than .01 occur from 1 - 5, 1111 - 1116, 2221 - 2226, and 3332. To get a line that does not wrap on itself the values must be sorted on `phases`. If the values represent a time series, then the data really do loop back so eliminating that line would misrepresent the data. – dcarlson Jul 10 '21 at 03:44
  • @Woj **For the future: Please refrain from using dropbox or similar to keep Q&A reproducible, you might want to consider our great guidelines in R tag: [how-to-make-a-great-r-reproducible-example](https://stackoverflow.com/a/5963610/6574038), thanks! This time I made an exception for you.** – jay.sf Jul 10 '21 at 12:26

1 Answers1

0

Just a minor fix sorting the data using order().

dat <- read.table('test.dat', header=TRUE)

o <- order(dat$phases)
op <- par(mar=c(5, 5, 4, 3)+.1)  ## to fix the ylab issue
with(dat, plot(x=phases[o], y=mag.lambdas[o], 
               main=paste("Set D Light Curve", sep=" "), 
               type="l", pch=3, col="purple", xlab=expression("Phase"), 
               ylab=expression("Absolute Magnitude (mags)"), cex.main=1.60, 
               cex.lab=1.50, cex.axis=1.80))
par(op)  ## reset to defaults

enter image description here


Example data (reduced):

dat <- structure(list(phases = c(0.109120693761022, 0.185397836784117, 
0.249938230401199, 0.30822778363147, 0.363435269696223, 0.455084249279825, 
0.543552820242301, 0.655747752044217, 0.774866453366206, 0.856206594036075, 
0.982585270988032, 0.100415444179982, 0.178014804373087, 0.243589226128645, 
0.302336457676285, 0.357806463203636, 0.438138755151517, 0.534438861334455, 
0.642183464272524, 0.765461100969384, 0.848464475619498, 0.965588333338646, 
0.0917064615210546, 0.170566091284324, 0.237176977834675, 0.296375445141231, 
0.352149626454385, 0.420152568949603, 0.525048346872039, 0.628312433306401, 
0.75484614531608, 0.840001508109705, 0.947550129709331), mag.lambdas = c(-2.60908535740988, 
-2.60768038551774, -2.73345412091621, -2.79093891301878, -2.85664469201418, 
-2.9379744328431, -3.07326641740626, -3.17106458057106, -2.97427279239455, 
-2.8699631559454, -2.68495601145474, -2.61243148043341, -2.60591330325558, 
-2.6375863091666, -2.78291529193605, -2.85146326816402, -2.93295354167362, 
-3.0573674843861, -3.1712588336948, -3.03203368817616, -2.87787161464618, 
-2.69569380800697, -2.61638329170682, -2.60465158131301, -2.63317322633531, 
-2.77584913218085, -2.84624680934001, -2.93274737295461, -3.04100660609613, 
-3.16794769204494, -3.05057297981154, -2.88664628320297, -2.79770401055239
)), row.names = c(100L, 200L, 300L, 400L, 500L, 600L, 700L, 800L, 
900L, 1000L, 1100L, 1200L, 1300L, 1400L, 1500L, 1600L, 1700L, 
1800L, 1900L, 2000L, 2100L, 2200L, 2300L, 2400L, 2500L, 2600L, 
2700L, 2800L, 2900L, 3000L, 3100L, 3200L, 3300L), class = "data.frame")
jay.sf
  • 60,139
  • 8
  • 53
  • 110