Message Boards Message Boards

A simple plot of an Excel file imported and plot list

I have the following excel file

In[2]:= mir = Import["C:UsersJoseSkyDriveUPRMChemistryQUIM6005Lab\n    alcanos_Test.xlsx"]

Out[2]= {{{"", 12493.2, 12489.4, 12485.5, 12481.7, 12477.8, 12474., 
   12470.1, 12466.2, 12462.4, 12458.5}, {"cyclohexane", 0.276776, 
   0.27676, 0.276708, 0.276677, 0.276705, 0.276706, 0.276645, 
   0.276571, 0.276525, 0.276499}, {"cyclohexane", 0.276847, 0.27689, 
   0.276958, 0.276965, 0.276872, 0.276735, 0.276633, 0.276566, 
   0.276529, 0.276526}, {"cyclohexane", 0.276413, 0.276385, 0.276354, 
   0.276301, 0.276295, 0.276334, 0.276303, 0.276198, 0.27609, 
   0.275997}, {"n-decane", 0.27176, 0.271841, 0.271928, 0.271913, 
   0.271835, 0.271789, 0.271792, 0.271792, 0.271788, 
   0.271801}, {"n-decane", 0.271916, 0.271873, 0.271918, 0.271944, 
   0.271873, 0.271789, 0.271784, 0.271838, 0.271884, 
   0.271882}, {"n-decane", 0.271787, 0.271845, 0.271925, 0.27193, 
   0.271869, 0.271817, 0.271824, 0.271824, 0.27177, 
   0.271722}, {"n-Heptane", 0.264859, 0.264852, 0.26487, 0.264881, 
   0.264891, 0.264904, 0.26491, 0.264898, 0.264892, 
   0.264882}, {"n-Heptane", 0.265164, 0.265183, 0.26521, 0.265159, 
   0.265074, 0.265036, 0.26507, 0.265121, 0.265103, 
   0.265042}, {"n-Heptane", 0.264663, 0.264693, 0.264705, 0.264668, 
   0.26462, 0.26461, 0.264625, 0.264608, 0.264548, 
   0.264487}, {"n-Hexane", 0.255916, 0.2559, 0.255895, 0.255872, 
   0.255845, 0.25583, 0.255837, 0.255863, 0.255883, 
   0.255885}, {"n-Hexane", 0.2559, 0.255884, 0.2559, 0.255901, 
   0.255872, 0.255835, 0.255816, 0.255797, 0.255777, 
   0.25577}, {"n-Hexane", 0.256151, 0.256187, 0.256213, 0.25618, 
   0.256132, 0.256103, 0.256091, 0.256106, 0.256161, 
   0.256182}, {"n-octane", 0.270985, 0.270966, 0.270922, 0.270885, 
   0.270873, 0.270875, 0.270892, 0.270901, 0.270883, 0.270868}}}

As I hope that you will see, this is an array holding the lists data from multiple experiments. I need to do a ListLinePlot[mir] , but getting en error. I assume that the first line is the problem, but I do not know how to set this to be the experiment name followed by the data in the column.

POSTED BY: Jose Calderon
2 Replies
Posted 11 years ago

Hi Jose

I'm not too sure if this will be the solution you are looking for, also not too sure if this will make any difference to the inputted array, (it's nested 3 deep after the import as it stands), however lets try this. I like to set my directory path before hand as in like this

SetDirectory["C:\\Users\\Jose\\SkyDrive\\UPRM\\Chemistry\\QUIM6005Lab"] (Note the double forwardslash between words)

and then when you do an import you only need specify the file like so.

mir=Import["alcanos_Test.xlsx"].

It may also be advisable to add the type of input after the name of the file as in.

mir=Import["alcanos_Test.xlsx",{"Data"}].

Now looking at the first line the numbers seem a lot bigger than the rest, are they part of the experiment? and do they need to be plotted? if not we could remove it and if after trying the altered way to import and it is still nested 3 deep we need to flatten it like this

mir1 = Flatten[mir, 1][[2 ;;]].

and then plot it

ListLinePlot[mir1]

Also not too sure about the name of the file is it "n alcanos_Test.xlsx" ? All those spaces between n and alcanos?, however this might work

SetDirectory[
  "C:UsersJoseSkyDriveUPRMChemistryQUIM6005Lab"];
mir = Import["alcanos_Test.xlsx"]; mir1 = 
 Flatten[mir, 1][[2 ;;]]; ListLinePlot[mir1]

Try adding the "Data" part too see if it makes a difference

Paul.

POSTED BY: Paul Cleary

How about,

ListPlot[First[mir], PlotLegends -> mir[[1, All, 1]]]
POSTED BY: David Reiss
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract