0

If I have multiple variables y1, y2, y3, y4 for y-axis and phi values for x-axis, then how do I plot these variables, indicating each variable with different black marker? My code is

data=Import["simavg1.xls",{"Data",1}]; 
phi=data[[All,1]]; 
csrp=data[[All,2]]; 
crl=data[[All,3]]; 
cArp=data[[All,4]]; 
Plot[{csrp,crl,cArp},phi]

but does not work.

bbgodfrey
  • 61,439
  • 17
  • 89
  • 156
Amin
  • 81
  • 5

1 Answers1

3

What you need to do is take each of your lists of y-values into a list of {x, y} pairs. To do this, you Transpose each of them with the phi list. This would work,

ListPlot[Transpose[{phi, #}] & /@ {csrp,crl,cArp}]

But if all of your lists are initially in the data array, then all you should have to do is define the lists including the x-values from the getgo,

csrp=data[[All,{1,2}]]; 
crl=data[[All,{1,3}]]; 
cArp=data[[All,{1,4}]];

and now you can just use

ListLinePlot[{csrp,crl,cArp}]
Jason B.
  • 68,381
  • 3
  • 139
  • 286
  • dear how to change the dashed colors and plot legends above the graph in this command ListLinePlot[{csrp,crl,cArp},Frame->True,FrameLabel->{Style["[Phi]",Black,Bold],Style["Average (%) Influence Detection",Black,Bold]},PlotLegends->{"!(*SubscriptBox[(D), ([Chi])])","!(*SubscriptBox[(D), (l)])","!(*SubsuperscriptBox[(D), ([Chi]), (A)])"},PlotStyle->{Dashing,Dotted,Dashed},PlotLabel->"(a) n=50"] – Amin Feb 17 '16 at 15:53
  • @Amin try something like PlotStyle -> {{Red, Dashed}, {Blue, Dotted}, {Purple, Dashed}} – Jason B. Feb 17 '16 at 15:59
  • Thanks and what about plot legends position on the graph instead of Right side? – Amin Feb 17 '16 at 17:20
  • Dear How I plot this data with respective axis labels – Amin May 18 '16 at 01:00