# Plot list over same x values?

I have a list that looks like this:

list = {{2}, {3}, {5, 2}, {9, 3, 5}};


I want a plot that looks like this:

Is there a simple way to do this?

• @Nasser no, that's not what I want--I'd like the numbers grouped together in the list to be plotted right on top of each other, as shown in the picture. Commented Oct 5, 2016 at 1:58
• Ok, will think more. Commented Oct 5, 2016 at 1:59

list = {{2}, {3}, {5, 2}, {9, 3, 5}};
ListPlot@Flatten[#, 1] &@(Tuples /@ MapIndexed[{#2, #1} &, list])


Or in case you want them to have different colors:

ListPlot[#, PlotStyle -> {Blue, Red, Green, Orange}] &@
(Tuples/@MapIndexed[{#2, #1} &, list])


list = {{2}, {3}, {5, 2}, {9, 3, 5}};
r = Table[{Red, PointSize[.02], Point[{i, #}] & /@ list[[i]]}, {i,Length[list]}];
Graphics[r, Axes -> True, AspectRatio -> 1, AxesOrigin -> {0, 0},
GridLines -> Automatic, GridLinesStyle -> LightGray]


list = {{2}, {3}, {5, 2}, {9, 3, 5}};

n = 1; list2 = Thread[{n++, #}] & /@ list

(*  {{{1, 2}}, {{2, 3}}, {{3, 5}, {3, 2}}, {{4, 9}, {4, 3}, {4, 5}}}  *)

ListPlot[list2, AxesOrigin -> {0, 0}]


This is similar to BlacKow's answer, in that MapIndexed[] is the key function for adding the abscissas:

ListPlot[MapIndexed[Transpose[PadRight[{#2, #1}, Automatic, #2]] &, list],
AxesOrigin -> {0, 0}, GridLines -> Automatic]


If they are meant to be part of just one set of data, add a Flatten[]:

ListPlot[Flatten[MapIndexed[Transpose[PadRight[{#2, #1}, Automatic, #2]] &, list], 1],
AxesOrigin -> {0, 0}, GridLines -> Automatic]


Another way to use MapIndexed:

ListPlot[MapIndexed[Thread[{#2[[1]], #}] &, list],
PlotStyle -> PointSize[.03], PlotRange -> Full, Frame -> True, PlotRangePadding -> 1]


or MapThread

ListPlot[MapThread[Thread[{##}] &, {Range@Length@list, list}],
PlotStyle -> PointSize[.03], PlotRange -> Full, Frame -> True, PlotRangePadding -> 1]


Another method:

list = {{2}, {3}, {5, 2}, {9, 3, 5}};


Add e.g. PlotStyle -> Blue for uniform styling: