2
$\begingroup$

I have data {x, y} where x starts at -25 degrees and goes up to +25 degrees in 1 degree steps, and then comes back down to -25 degrees in 1 degree steps again.

I want to plot this sinusoidal-type data without the y-data overlapping in the ranges -25 - +25 degrees. I have attached an image of the kind of graph I am after.

enter image description here

How does one do this?

$\endgroup$
9
$\begingroup$

You can always use Manual Tick specifications:

ticks = Join[Range[-25, 25, 5], Range[20, -25, -5]];
data = Table[{x, RandomInteger[10]}, {x, ticks}];

now the plot. the [[;; ;; 2]] selects just every second tickmark. Note that I plot the y-data just against their index and not against their x-value.

ListLinePlot[data[[All, 2]],  
  Ticks -> {Transpose[{Range@Length[data], ticks}][[;; ;; 2]], Automatic}]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.