# Most elegant way to plot from you data file (xy, xy, xy... format)

I have a simple question and it could be very basic tips for many. I tried to find the answer several hours by searching, but couldn't find the way yet. My question is, if I have a data set (x1y1, x2y2, x3y3, x4y4...). What's the most simple and elegant way to plot this data set? How would you do it? Many many thanks in advance.

testdata = {{"", "1st", "", "2nd", "", "3rd", "", "4th"}, {"C", "%",
"", "", "", "", "", ""}, {"temp", "result", "", "", "", "", "",
""}, {20, 100, 20, 56, 20, 48, 20, 54}, {40, 98, 40, 85, 40, 45,
40, 56}, {60, 39, 60, 64, 60, 73, 60, 45}, {80, 59, 80, 84, 80,
14, 80, 5}, {100, 95, 100, 49, 100, 85, 100, 97}};
TableForm@testdata
ListLinePlot[testdata, Frame -> True, Axes -> False,
PlotLegends -> testdata[[1]],
FrameLabel -> (Style[#, 14] & /@ {testdata[[3, 1]],
testdata[[3, 2]]})]


• The answers of this question depend on the data dimensions and interpretation. The better approaches to visualize categorical data with low number of variables are different than those for numerical data. From the question it is not clear are the "result" columns of testData numerical physical quantity values or contingency values (counts). Feb 28, 2016 at 19:26

You need to fundamentally reorganize your data set, and select out empty columns from your plot legend definitions:

reorg = Transpose[{testdata[[4 ;;, 1]], #}] & /@
Transpose@testdata[[4 ;;, 2 ;; ;; 2]];

ListLinePlot[
reorg,
Frame -> True, Axes -> False,
PlotLegends -> testdata[[1, 2 ;; ;; 2]],
FrameLabel -> (Style[#, 14] & /@ {testdata[[3, 1]], testdata[[3, 2]]})
]


• Thank you MarcoB for your answer. I will try to learn from your code how to reorganize data-set. Feb 28, 2016 at 4:09
• @SungwooYang You are welcome. I'd suggest, however, that it will be much easier on you to generate your data in a more "Mathematica - friendly" way. Feb 28, 2016 at 4:15
• I am not sure what is the more mathematica friendly way, but I will definitely try to look and learn. Thank you as always. You're awesome. Feb 28, 2016 at 4:23
• Another way: Transpose[Partition[#, 2] & /@ Drop[testdata, 3], {2, 1, 3}]. Feb 28, 2016 at 12:23