I have the following code


  6.3e-05 0.8767984145412976 0.6
  0.000125 12.85965577546382 9.970000000000001
  0.00025 16.95140970189756 13.76
  0.0005 14.61328253838453 12.13
  0.001 21.24630316052836 17.76
  0.002 33.45255040918443 27.81
  0.004 0 17.97
  0.0056 0 0
  0.008 0 0
  0.0112 0 0
  0.016 0 0
  0.0224 0 0
  0.0315 0 0


  /pgf/bar width=5pt,
  bar cycle list,
  scale only axis,
  ymin=0, ymax=100, 
  tick label style={font=\scriptsize},
  x tick label style={/pgf/number format/sci},
  xticklabels from table={\datatable}{0}
  \addplot table[x expr=\coordindex,y=1]{\datatable};
  \addplot table[x expr=\coordindex,y=2]{\datatable}; 

which gives me this plot

enter image description here

Now instead of the fixed format for the xticklabels I want the scientific format and want an xtick on every delivered coordinate. How do I achieve this? I tried it with x tick label style={/pgf/number format/sci} but that did not help.


To have every xtick I had to use the option xtick=data.

  • So you are trying to avoid the overlap? – percusse Jun 30 '13 at 10:07
  • No that's not the problem, I can use rotate=90. I just want the label in the scientific format like 1.25e-4 and so on. – Reza Jun 30 '13 at 10:12
  • 2
    The key xticklabels from table has been introduces for symbolic data, i.e. it does not apply the number printer at all. Might be a feature request. Do you need xticklabels from table? – Christian Feuersänger Jun 30 '13 at 10:37
  • 1
    Yes that would be great to have such a feature – Reza Jun 30 '13 at 10:52
  • @ChristianFeuersänger I would benefit from this feature too. – M. Toya Jul 8 '13 at 9:28

1 xtick=data means the x-axis from data.

2 But xticklabels from table means the x-axis format from data.

That is, if you want the legend read from \datatable, use first method.

The example from PGFplots Official website shows the difference in two methods. The example 323(or in Manual version 1.8 page 302)

    xmin=-4.7124, xmax=4.7124,
    xticklabels={$-\frac{3}{2} \pi$,$-\pi/2$,$\pi/2$,$\frac{3}{2} \pi$},

Note that xtick refers to values, and xticklabels refers to format.

So if I change your code,xticklabels from table={\datatable}{0} to xtick=data, it's done. But it is ugly then.

| improve this answer | |
  • 1
    The idea is that number printing is bypassed when labels are loaded from table. For example, if I had an extra column just for the labels then your solution wouldn't work since xticks and the labels would be different – percusse Aug 29 '13 at 10:48
  • Could you explain more about "extra column just for the labels"? I don't get it. – selwyndd21 Aug 30 '13 at 4:02
  • Add another column to the table starting from 17 to 30 and I want to use it as labels using scientific notation(can be more complicated). Then xtick trick doesn't work. That's why it's a feature request given in the comments. – percusse Aug 30 '13 at 8:07

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.