I want to construct a plot with package pgfplots using data from a table named "00-data.txt". Following is a part of this table.

id a b  time
1  1 1  23:59:58
2  2 4  23:59:59
3  3 9  00:00:00
4  4 16 00:00:01
5  5 25 00:00:02

The pgfplots option xticklabels from table={00-data.txt}{time} is used to get xticklabel with the data from the column "time".

Yet the xticklabel does not begin with 23:59:58, but 00:00:00(please see the attached figure).

I know the option xtick=data would solve this problem, but there are nearly 10 thousands rows of data in the table, xtick=data would cause too many xticklabels shown on the plot which overlap side by side.

Is there a better way to deal with this problem?

And how to get a dual-xticklabel in a plot, for example, both "id" and "time" are shown in the plot as xticklabel?

Here is my MWE:


title={xtick=data not used},
xticklabel style={rotate=90},
xticklabels from table={00-data.txt}{time} 
\addplot [blue] table {00-data.txt};
\addplot table[x=id,y=b] {00-data.txt};


enter image description here

  • @marmot I tyied your proposal, but get error message "ERROR: Package pgfplots Error: Sorry, could not retrieve column '' from table '00-data.txt'. Please check spelling (or introduce name aliases).." – lyl Dec 3 '18 at 13:00
  • As I don't know how to upload a data file, I provide with the truncated data in my description before my MWE. Copy them directly into a text file(named "00-data.txt" will make a data file. – lyl Dec 3 '18 at 13:47
  • I have no clue what's going on here. And unfortunately I am blocked right now. – user121799 Dec 3 '18 at 15:37

Your Answer

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

Browse other questions tagged or ask your own question.