I have a problem implementing a tikzpicture. I want to plot the Swiss Performance Index, which I was able to do time ago. Unfortunately I deleted the code from my thesis because I thought I will not include that diagram. Meanwhile I think I will use that in the thesis. But I get error messages all the time and I have no clue what I did different. Here is my code:


        \addplot table[x=Datum, y=Schluss] {SMIhist.txt};



The inputs I have in the SMIhist.txt file. The entries look like this:

Datum    Schluss

2013-09-09  7'537.70    
2013-09-06  7'549.36

As I mentioned before: it worked once but now I get the following error messages:

./Vorlage.tex:494: Package PGF Math Error: Could not parse input '7'537.70' as 
a floating point number, sorry. The unreadable part was near ''537.70'..

See the PGF Math package documentation for explanation.
Type  H <return>  for immediate help.
 ...            NOTE: coordinate (2013-09-09,7'537.70) has been dropped because it     is unbounded
 (in y). (see also unbounded coords=jump). 

What do I do wrong?


That happens because of the ' in your Schluss column, which throws off the number parser. You need to tell PGFPlots to ignore that character when parsing the data, by setting

\addplot table [x=Datum, y=Schluss, ignore chars='] {SMIhist.txt};

To fix the error with your Datum column, you need to load the dateplot library using \usepgfplotslibrary{dateplot}, and specify that the x coordinates are dates by setting date coordinates in=x in your axis options.

  • I'm still getting the following error: ./Vorlage.tex:494: Package PGF Math Error: Could not parse input '2013-07-01' a s a floating point number, sorry. The unreadable part was near '-07-01'..] – Honsell Sep 23 '13 at 9:00
  • @Honsell: I've edited my answer. In general, it's best if you post full minimal example documents instead of just code snippets like the one in your question. That takes the guesswork out of what the error source might be (I was assuming that you had loaded the dateplot library in your real document). – Jake Sep 23 '13 at 9:07
  • I've loaded the dateplot library but forgot setting date coordinates in=x. Not it works perfectly. Thanks a lot! – Honsell Sep 23 '13 at 9:10

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.