0
$\begingroup$

I want to build:

ListLinePlot[{en, v1} // Transpose]

I want:

enter image description here

but the third plot is a problem:

 data1={1,2,3,4,5, 6, 7, 8, 9, 10} (* number of points *)
 data2={3.3, 3.1, 3, 3.5, 3.13, 2.4, 2.12, 2.87, 4.3, 5} (* values of voltage *)
 data3={14, 27, 125, 256, 350, 14, 19, 126, 250, 310} (*values of angle*)

ListLinePlot[{data1, data2}// Transpose] (*It's Okey*)

ListLinePlot[{data1, data3}// Transpose] (*It's Okey*)

ListLinePlot[{data3, data2}// Transpose] (*Picture below*)

The X-axis is not equal to the number of points.

$\endgroup$
  • 1
    $\begingroup$ Did you try to sort the list of points? $\endgroup$ – Riccardo Cazzin Mar 14 '17 at 22:48
  • 1
    $\begingroup$ Probably not. How to do it? I try to apply "Thread" and MapIndexed, but there was a mistake in the syntax. $\endgroup$ – Alex Mar 14 '17 at 22:53
  • $\begingroup$ If the list of points is like {{x1,y1},{x2,y2},{x3,y3}}, then Sort[list, #[[1]]<#2[[1]]&] is quite good. See the complete syntax in the Documentation. $\endgroup$ – Riccardo Cazzin Mar 14 '17 at 22:55
  • 1
    $\begingroup$ Do those answers fit your needs? 137444 $\endgroup$ – Kuba Mar 14 '17 at 23:04
  • 1
    $\begingroup$ No, I want to replace data 2 with data 3, but with the values saved by the number of points. In the figure above, the X axis contains data 3, but they are not in order, and there are in the range from 0 to 359. But axis X must be in the range [0 ... number points] with different values [0...359] $\endgroup$ – Alex Mar 14 '17 at 23:06
1
$\begingroup$

So working from the data sample you provided for Kuba in a comment we have this:

data1 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
data2 = {3.3, 3.1, 3, 3.5, 3.13, 2.4, 2.12, 2.87, 4.3, 5};
data3 = {14, 27, 125, 256, 350, 14, 19, 126, 250, 310};

Row@
 {
  Transpose@{data1, data2} //
   ListLinePlot[#, ImageSize -> 200] &,
  Transpose@{data1, data3} //
   ListLinePlot[#, ImageSize -> 200] &,
  SortBy[Transpose@{data3, data2}, First] //

   ListLinePlot[#, ImageSize -> 200] &
  }

Which gives this as the output:

plots

Obviously this is dataset too small to know if that's really what you wanted but try it out with the full data.

So I think what you're actually trying to get at is labelling that first plot with the angle values. Here's a way to do it:

ListLinePlot[
 Transpose@{data1, data2},
 Ticks -> {
   MapIndexed[{First@#2, #} &, data3],
   Automatic
   }
 ]

enter image description here

$\endgroup$
  • $\begingroup$ Yes, It is alright. Thank you so much. $\endgroup$ – Alex Mar 15 '17 at 6:47
  • $\begingroup$ @Alex so then your problem was what Riccardo Cazzin identified. Namely your points needed to be sorted (this was I think everyone's guess from the plots you provided). $\endgroup$ – b3m2a1 Mar 15 '17 at 6:48
  • $\begingroup$ I looked at the answer carefully, and still it's a bit wrong. I want 10 values on the X axis, but only so that they are not in order, but in the same sequence as originally at data3. $\endgroup$ – Alex Mar 15 '17 at 7:00
  • $\begingroup$ @Alex If they aren't in order in terms of their x-values the line going between them will be a zig-zagging mess, as you saw. Do you want something like ListPolarPlot? You said that data3 is a bunch of angles. $\endgroup$ – b3m2a1 Mar 15 '17 at 7:06
  • $\begingroup$ I want ListLinePlot, but that instead of the number of points along the X axis, the values of the angle without sorting are assigned. Example Axis X must: {35, 48,167,270,358,24,59,79 and etc.}, that is, instead of the values of the points, the values of the angle without sorting are substituted. $\endgroup$ – Alex Mar 15 '17 at 7:12

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.