Message Boards Message Boards

Plot data imported from an Excel file?

Posted 7 years ago

How can I Plot imported files in Mathematica?

It didn't work like this:

Import["/Users/AKay/Downloads/Hausaufgabe2/Daten Solar-Wind-Last \
2012-2015.xls"]
data = "Daten Solar-Wind-Last 2012-2015.xls";

ListPlot[data]
Attachments:
POSTED BY: Azad Kaygun
6 Replies

It is meant to translate the dates as strings, for example "10.12.2015", into Mathematica dates. You may avoid this cleanup if, instad of Import, you used SemanticImport, but I am not familiar with that command.

POSTED BY: Gianluca Gorni

What's the meaning of this part?

/. {dt_String, 
     numbers__?
      NumericQ} :> {DateObject[{dt, {"Day", ".", "Month", ".", 
        "Year"}}], numbers};
POSTED BY: Gianluigi Salvi
Posted 7 years ago

Thank you so far, now I got the Issue that i need three different graphs for wind, solar, and last how can I arrange that? Besides I need a graphic for every year and not all together

POSTED BY: Azad Kaygun

You can control the time range with PlotRange. For example

data = {{{2006, 10, 1}, 10}, {{2006, 10, 15}, 12}, {{2006, 10, 30}, 
    15}, {{2006, 11, 20}, 20}};
DateListPlot[data]
DateListPlot[data, 
 PlotRange -> {{{2006, 10, 1}, {2006, 10, 30}}, All}]

Your records are made of quadruples of the form {time, v2, v3, v4}. You can plot v2, v2, v4 separately against time:

DateListPlot[cleanedData[[All, {1, 2}]]]
DateListPlot[cleanedData[[All, {1, 3}]]]
DateListPlot[cleanedData[[All, {1, 4}]]]
POSTED BY: Gianluca Gorni
Posted 7 years ago

Besides the issues that Gianluca Gorni pointed out, you have a single "\" which needs to be "\" (or be more consistent with the forward slashes that you have everywhere else and the extra spaces around the single "\" might be an issue, too).

Daten Solar-Wind-Last \ 2012-2015.xls should be Daten Solar-Wind-Last\\2012-2015.xls or Daten Solar-Wind-Last/2012-2015.xls.

**Update: Sorry. I didn't read carefully enough. That "\" is simply in there when you pasted in the text. Please ignore my comment. **

POSTED BY: Jim Baldwin

First you import the file into mathematica as

myData = Import["file path"]

Then you clean up the data, for example with

cleanedData = 
  myData[[1, 3 ;; -1]] /. {dt_String, 
     numbers__?
      NumericQ} :> {DateObject[{dt, {"Day", ".", "Month", ".", 
        "Year"}}], numbers};

Then you can plot with DateListPlot:

DateListPlot[cleanedData[[All, {1, 3}]]]
POSTED BY: Gianluca Gorni
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