# Avoid too many curly brackets to break ListPlot?

Posted 3 months ago
321 Views
|
3 Replies
|
1 Total Likes
|
 Consider the following code: In[30]:= x = ( { {1}, {1} } ); R = ( { {1}, {1} } ); L = RandomReal[{0, 0.1}, {2, 2}]; S = RandomReal[{0, 0.1}, {2, 2}]; T = RandomReal[{0, 0.1}, {2, 2}]; p[x_] := Table[ Part[x, k] + Part[(L - S).x, k]*Part[R - T.x, k], {k, 2}] NestList[p, x, 2] Out[36]= {{{1}, {1}}, {{0.948118}, {0.994829}}, {{0.897341}, \ {0.990481}}} In[29]:= ListPlot[{{{1}, {1}}, {{0.9880109687567669}, \ {1.0122120961249677}}, {{0.9753474700122722}, \ {1.0241614824319665}}}] Out[29]= \!$$\* GraphicsBox[{{}, {{}, {}, {}}, {}, {}, {}, {}}, AlignmentPoint->Center, AspectRatio->0.6180339887498948, Axes->{True, True}, AxesLabel->{None, None}, AxesOrigin->{0, 0}, AxesStyle->{}, Background->None, BaseStyle->{}, BaselinePosition->Automatic, ColorOutput->Automatic, ContentSelectable->Automatic, CoordinatesToolOptions:>Automatic, DisplayFunction->Identity, Epilog->{}, FormatType:>TraditionalForm, Frame->{{False, False}, {False, False}}, FrameLabel->{{None, None}, {None, None}}, FrameStyle->{}, FrameTicks->{{Automatic, Automatic}, {Automatic, Automatic}}, FrameTicksStyle->{}, GridLines->{None, None}, GridLinesStyle->Directive[ GrayLevel[0.5, 0.4]], ImageMargins->0., ImagePadding->All, ImageSize->Automatic, ImageSizeRaw->Automatic, LabelStyle->{}, Method->{"MessagesHead" -> ListPlot, "CoordinatesToolOptions" -> {"DisplayFunction" -> ({ (Identity[#]& )[ Part[#, 1]], (Identity[#]& )[ Part[#, 2]]}& ), "CopiedValueFunction" -> ({ (Identity[#]& )[ Part[#, 1]], (Identity[#]& )[ Part[#, 2]]}& )}}, PlotLabel->None, PlotRange->{{0, 1}, {0, 1}}, PlotRangeClipping->True, PlotRangePadding->{{ Scaled[0.02], Scaled[0.02]}, { Scaled[0.02], Scaled[0.05]}}, PlotRegion->Automatic, PreserveImageOptions->Automatic, Prolog->{}, RotateLabel->True, Ticks->{Automatic, Automatic}, TicksStyle->{}]$$ In[38]:= ListPlot[{{{1}, {1}}, {0.9880109687567669, 1.0122120961249677}, {0.9753474700122722, 1.0241614824319665}}] Out[38]= \!$$\* GraphicsBox[{{}, {{}, {RGBColor[0.560181, 0.691569, 0.194885], PointSize[ 0.012833333333333334], AbsoluteThickness[1.6], PointBox[{{0.9880109687567669, 1.0122120961249677}, { 0.9753474700122722, 1.0241614824319665}}]}, {}}, {}, {}, {}, {}}, AspectRatio->0.6180339887498948, Axes->{True, True}, AxesLabel->{None, None}, AxesOrigin->{0., 1.0116146268096178}, DisplayFunction->Identity, Frame->{{False, False}, {False, False}}, FrameLabel->{{None, None}, {None, None}}, FrameTicks->{{Automatic, Automatic}, {Automatic, Automatic}}, GridLines->{None, None}, GridLinesStyle->Directive[ GrayLevel[0.5, 0.4]], ImagePadding->All, Method->{"CoordinatesToolOptions" -> {"DisplayFunction" -> ({ (Identity[#]& )[ Part[#, 1]], (Identity[#]& )[ Part[#, 2]]}& ), "CopiedValueFunction" -> ({ (Identity[#]& )[ Part[#, 1]], (Identity[#]& )[ Part[#, 2]]}& )}}, PlotRange->{{0., 0.9880109687567669}, {1.0122120961249677, 1.0241614824319665}}, PlotRangeClipping->True, PlotRangePadding->{{ Scaled[0.02], Scaled[0.02]}, { Scaled[0.05], Scaled[0.05]}}, Ticks->{Automatic, Automatic}]$$ The following program results in an empty plot window with nothing plotted. When I remove the innermost curly brackets manually from each data vector, then ListPlot works. My actual data consists of 10,000 pairs of vectors, so the manual operation is not feasible. How to prevent ListPlot from Choking on the data?
3 Replies
Sort By:
Posted 3 months ago
 Paul,The problem is that you are giving ListPlot a matrix instead of a list of x-y points. You can easily reformat your data into the correct format for ListPlot with jnk = NestList[p, x, 2]; ListPlot[Map[Flatten[#, 2] & , jnk]] Regards,Neil
 This will also work: ListPlot[Flatten[jnk, {{1, 3}, {2}}]] by using Flatten only and not using Map.