# How to plot multiple graphs with same x-axis values on the same graph? [closed]

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.

• Have a look at Plot. Feb 17, 2016 at 13:01
• dear look but unable to enter phi values on x-axis. my commands are 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]
– Amin
Feb 17, 2016 at 13:03
• Consider using ListPlot. Feb 17, 2016 at 13:19
• have you seen Customizing a graph (Dashing, PlotMarkers, Labeled)
– user9660
Feb 17, 2016 at 13:34
• Also consider PlotTheme -> "Monochrome" if you are using a recent version of Mathematica, e.g. ListLinePlot[ Table[{k, PDF[BinomialDistribution[50, p], k]}, {p, {0.3, 0.5, 0.8}}, {k, 0, 50}], Filling -> Axis, PlotLegends -> {0.3, 0.5, 0.8}, PlotTheme -> "Monochrome"] Feb 17, 2016 at 17:49

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}]

• 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, 2016 at 15:53
• @Amin try something like PlotStyle -> {{Red, Dashed}, {Blue, Dotted}, {Purple, Dashed}} Feb 17, 2016 at 15:59
• Thanks and what about plot legends position on the graph instead of Right side?
– Amin
Feb 17, 2016 at 17:20
• Dear How I plot this data with respective axis labels
– Amin
May 18, 2016 at 1:00