0
$\begingroup$

I have to plot a huge amount of data. I have only one file, I've already imported it. The file contains the following:

48 separate smaller fractions.

Every fraction begins with six numbers (which are unnecessary, for now) and it is followed by four larger vectors, the first three has nineteen (x,y) elements and the last one has eightteen (x,y) pairs inside them.

It looks something like this:

data={{a,b,c,d,e,f,{{x1,y1},{x2,y2},...,{x19,y19}},{...},{...},{...}},{a1,b1,...}}

I'd like to plot every vector ({{x1,y1},{x2,y2},...,{x19,y19}}) in a separate subplot with ListLinePlot, but all four in one row. For all of the 48 fractions. So, as a result, the whole plot would contain 48 rows and 4 columns of subplots.

{a,b,c,d,e,f} are needed in naming every graph, but that's a separate problem.

I'm relatively new to Mathematica. Can anyone help me how to plot this monster?

$\endgroup$
  • 1
    $\begingroup$ Hi Dávid, welcome to MMA.SE! Would you be able to share your data - perhaps with something like CloudPublish[mydata], and add the link to your question? It's a little hard to parse what your data is like from your description. Also, would it be possible to include a longer description of what the plot you envision looks like? That would help us in coming up with a solution for you. $\endgroup$ – Carl Lange Jan 21 '19 at 19:52
  • $\begingroup$ My belief is that the data given by this expression is roughly the same format as the data you talk about - is that correct? dat = Table[{1, 2, 3, 4, 5, 6, Table[RandomReal[1, {2}], 19], Table[RandomReal[1, {2}], 19], Table[RandomReal[1, {2}], 19], Table[RandomReal[1, {2}], 18]}, 48]; If so, just a more thorough description of the type of plot you expect would be necessary. For instance, ListPlot[#[[{7, 8, 9, 10}]], PlotLabel -> #[[{1, 2, 3, 4, 5, 6}]]] & /@ dat would be a way to plot this data. $\endgroup$ – Carl Lange Jan 21 '19 at 19:57
  • $\begingroup$ Yes, it is correct. I know, I should start with something easier, but this is the task I have to do. The plots are nothing special, I want to have a huge figure, with 4*48 plots, each subplot with the first six numbers in the title. These data are imported from a given file (they're results of many simulations). $\endgroup$ – Dávid Fertig Jan 21 '19 at 20:00
  • $\begingroup$ I want to use ListLinePlot to plot the {x,y} data. $\endgroup$ – Dávid Fertig Jan 21 '19 at 20:07
  • $\begingroup$ Please check the edit to my answer and see if it solves your problem. $\endgroup$ – Carl Lange Jan 21 '19 at 20:35
2
$\begingroup$

Generate data in the same format as what you have:

gen[l_] := RandomFunction[RandomWalkProcess[.5], {0, l}]["Path"]
dat = Table[{1, 2, 3, 4, 5, 6, gen[19], gen[19], gen[19], gen[18]}, 
  48]

Plot:

plots = Map[ListLinePlot[#[[{7, 8, 9, 10}]], 
   PlotLabel -> #[[{1, 2, 3, 4, 5, 6}]]] &, dat]

example plot

Since you have all these, you may consider something like TabView[plots] to make it easier to see individual lists.

You may also want to do something like:

Grid[Partition[plots, 6]]

to display the data in a uniform grid, like so:

grid

The upside to this is that the plots will more-or-less scale to fit into your notebook window.

It occurs to me that you may want 4 columns and 48 rows.

First we define a function to create plots with the same label (this is for each of the 4 vectors within each dataset):

p[dataarr_, label_] := Map[ListLinePlot[#, PlotLabel -> label] &, dataarr]

Now we use this function on all the 48 datasets:

plots = Map[p[#[[{7, 8, 9, 10}]], #[[{1, 2, 3, 4, 5, 6}]]] &, dat]

Then we can use Grid to display the data nicely:

enter image description here

| improve this answer | |
$\endgroup$
  • $\begingroup$ The plotting part is ok, thank you ;) I imported my file in the following way: cap = Import["E:\\testread\\Capacitance\\capdata.txt"] How should I tell Mathematica, that for every figure I want the seventh/eighth/whatever element (the whole vector, with the x,y pairs) of the n-th fraction of the imported file? Probably my question sounds a little obvious, but I want to learn how to do this. $\endgroup$ – Dávid Fertig Jan 21 '19 at 20:46
  • $\begingroup$ It's not completely clear what you're asking. If I understand you correctly you are looking for the Part operator, also known as [[ and ]]. So cap[[3]] might get you the third part, cap[[3, {7,8}]] might get you the 7th and 8th parts of the third part, and cap[[All, 9]] would get you the 9th part of all of cap. $\endgroup$ – Carl Lange Jan 21 '19 at 20:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.