4
$\begingroup$

Consider matrix

A = 
  {{0, 2.54343, 3.566, 4.2323, 2.3434}, 
   {0.1, 6.432, 4.6465, 5.656, 1.34},  
   {0.2, 0.3423, 1.6342, 3.323, 2.04}};

The x-axis values are 0, 0.1, 0.2. There are four y-axis values for each x-axis value.

How do I plot this?

Naive use of

ListPlot[A]

fails.

$\endgroup$

1 Answer 1

5
$\begingroup$

Transpose the list A , remove its first list and use the option DataRange:

ListPlot[Rest[Transpose@A], DataRange -> {0, .2}, Frame -> True, Axes -> False,
 PlotRangePadding -> Scaled[.1], BaseStyle -> PointSize[Large]]

enter image description here

Alternatively, create new input list with explicit x values for each point:

d1 = Thread[{A[[All, 1]], #}]& /@ Rest[Transpose@A];;
ListPlot[d1, Frame -> True, Axes->False, 
 PlotRangePadding -> Scaled[.1], BaseStyle -> PointSize[Large]]

same picture

You can also use TemporalData using {0, .1, .2} as the common time stamps:

d2 =  TemporalData[Rest/@ A, {A[[All,1]]}];;
ListPlot[d2, Frame -> True, Axes -> False, 
 BaseStyle -> PointSize[Large],  PlotRangePadding -> Scaled[.1]]

same picture

$\endgroup$
2
  • 1
    $\begingroup$ I'm guessing that the OP has A[[All,1]] as the x-values with A[[All,{2,3,4,5}]] as the y-values. $\endgroup$
    – JimB
    Jun 16, 2019 at 19:09
  • 1
    $\begingroup$ @JimB, thank you. Fixed the errors now. $\endgroup$
    – kglr
    Jun 16, 2019 at 19:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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