# Plotting multiple datasets for different sample that share the different length ( x-axis)

Hi I have some questions of the how can I plot the list of data that have different lengths.

In the graph, I would need to include an overall gradient.

The final goal of the graph should include:1) All the values of the sample in Y-axis. 2) X-axis to indicated the length. 3) The standard deviation of each sample. 4) The gradient fit, to understand the increase in length with the change in resistance correlation. See the below hand-drawn graph, as the example.

Can anyone help in this! Appreciate it! Thank you!

unstretch5S1A= {48.38, 48.37, 48.34, 48.31, 48.27, 48.22, 48.24, 48.15, 48.11, 48.11, 48.1, 48.08, 48.06, 48.06, 48.06, 48.05, 48.05, 48.06, 48.04, 48.06, 48.06, 48.05, 48.04, 48.04, 48.04, 48.03, 48.01, 48.01, 48.01, 48.01, 48, 48, 48, 48.01, 48, 48, 48, 48, 47.97, 47.95, 47.95, 47.94, 47.89, 47.87, 47.89, 47.88, 47.86, 47.85, 47.83, 47.84, 47.82, 47.84, 47.82, 47.82, 47.81, 47.81, 47.8, 47.79, 47.91, 47.41, 47.8}

unstretch7S1A={77.2, 77.1, 77, 77, 77, 77, 76.9, 76.9, 76.9, 76.9, 76.9, 76.9, 76.9, 76.9, 76.9, 76.9, 76.9, 77, 77, 77, 77, 77, 77, 77.1, 77.1, 77.1, 77.1, 77.1, 77.1, 77.1, 77.1, 77.1, 77.1, 77.1, 77.1, 77.1, 77.1, 77.1, 77.1, 77.1, 77.1, 77.1, 77.1, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 76.9, 76.9, 76.9}

unstretch10S1AX={126.9, 126.8, 126.6, 126.5, 126.4, 126.3, 126.3, 126.2, 126.2, 126.1, 126.1, 126.1, 126, 126, 126, 126, 126, 126, 126, 126, 125.9, 125.9, 125.9, 125.9, 125.9, 125.9, 125.9, 125.9, 125.9, 125.9, 126.8, 126.8, 126.8, 126.8, 126.8, 126.8, 126.8, 125.7, 125.7, 125.7, 125.7, 125.7, 125.7, 125.7, 125.7, 125.7, 125.7, 125.7, 125.7, 125.6, 125.6, 125.6, 125.6, 125.6, 125.6, 125.6, 125.6, 125.5, 125.5, 125.5, 125.5}

unstretch27S1A={470.5, 470.5, 470.5, 470.5, 470.4, 470.3, 470.1, 470, 470, 470, 470, 469.9, 469.9, 469.8, 469.6, 469.6, 469.5, 469.5, 469.5, 469.3, 469.2, 469.1, 469.1, 469, 469, 468.7, 468.5, 468.4, 468.4, 468.4, 468.4, 468.2, 468.2, 468.1, 468, 468, 467.9, 467.8, 467.8, 467.7, 467.7, 467.7, 467.7, 467.6, 467.6, 467.5, 467.6, 467.5, 467.6, 467.5, 467.5, 467.5, 467.4, 467.4, 467.4, 467.4, 467.3, 467.3, 467.2, 467.2, 467.2}

unstretch30S1A= {327.5, 327.5, 327.5, 327.5, 327.5, 327.4, 327.3, 327.2, 327.2, 327.1, 327.1, 327.1, 327.1, 327.1, 327, 327, 327, 326.9, 326.8, 326.6, 326.6, 326.5, 326.5, 326.4, 326.4, 326.3, 326.3, 326.2, 326.1, 326.1, 326, 325.9, 325.8, 325.8, 325.7, 325.7, 325.6, 325.6, 325.6, 325.5, 325.4, 325.4, 325.2, 325.1, 325.1, 325.1, 325.1, 325.1, 325, 325, 324.9, 324.9, 324.9, 324.9, 324.9, 324.9, 324.8, 324.8, 324.8, 324.8, 324.8}

Combinegraph =
Join[{Transpose[unstretch5S1A][[2]], Transpose[unstretch7S1A][[2]],
Transpose[unstretch10S1AX][[2]], Transpose[unstretch27S1A][[2]],
Transpose[unstretch30S1A][[2]]}]

ListPlot[Transpose[Combinegraph]]
D1 = Flatten[Combinegraph];
Dimensions[D1]
D2 = Fit[D1, {1, x}, x]

• Are you sure you haven't swapped the 27 and the 30 data? I would have expected to have the 30data larger than the 27. Jun 9, 2018 at 9:01
• It's not swapped! it's the true values that I have recorded and I was surprised too.
– ljsg
Jun 10, 2018 at 3:15

Here some tips.

These are your data that you can plot and fit.

xAxis = {5, 7, 10, 27, 30};
yAxis = {unstretch5S1A, unstretch7S1A, unstretch10S1AX,
unstretch27S1A, unstretch30S1A};
data = Flatten[Inner[List, xAxis, yAxis, List], 1];


These are mean and stddev for each data set:

Transpose@{xAxis,
Mean /@ yAxis,
StandardDeviation /@ yAxis}


This is the fitting model:

fit = NonlinearModelFit[data, m*x + q, {m, q}, x]


This: http://reference.wolfram.com/language/ErrorBarPlots/ref/ErrorListPlot.html is the function you need to look at for assembling all the information I wrote above :) I'm sure it will be good for you if you try to put the pieces together by yourself!

Enjoy!

• Thank you! I will give it a try!
– ljsg
Jun 10, 2018 at 3:06