1

I am trying to load data from a table which looks like below and use the 'label' column for xticklabels.

idx,label,value
1,20040101_20050108.rotation.summary, 19.470949839091155
2,20040101_20050115.rotation.summary, 3.2633743485078925
3,20040101_20050122.rotation.summary, 2.6505513476912275
4,20040101_20050129.rotation.summary, 1.8865512077042033
5,20040101_20050205.rotation.summary, 2.2793107344143277

I have around 600 rows and when I used xtick=data with xticklabels from table={\mydata}{1} I am getting a plot like below.

enter image description here

So I tried to use xticklabel customization like below with \pgfplotstablegetelem.

\begin{tikzpicture}
  \begin{axis}[
    xmax=573,
    xticklabel={$\pgfplotstablegetelem{\tick}{1}\of{\mydata}$},
    xticklabel style={rotate=90, anchor=east}]
      \addplot[mark=none] table [
        x index={0},
        y index={2}] {\mydata};
 \end{axis}
\end{tikzpicture}

But what I got was following:

enter image description here

Please let me know if anyone has any ideas to fix this.

Update 1

I figured out that I should use \pgfplotsretval to get the element value and updated my plot to reflect that like below

...
xticklabel={$\pgfplotstablegetelem{\tick}{label}\of{\mydata}\pgfplotsretval$},
...

But the label still has prefix added to the beginning of each label like .000000002004010120061209.rotation.summary.

Update 2

I found the solution. xticklabel should be something like below.

{
  \pgfmathparse{int(round(\tick))}
  \pgfplotstablegetelem{\pgfmathresult}{[index]1}\of{\stresscculogerr}\pgfplotsretval
}
  • Welcome to tex.sx! Have you seen this question? –  May 01 '16 at 18:55
  • @Grimler, Thank you for your answer. I tried that. But it adds xtick labels for each tick. That doesn't work for me because I have around 600 data points. I just need to have labels for certain xticks as shown in above figures. Is there anyway that I can customized the linked answer to get xtick label outputs like I need. – Milinda Pathirage May 01 '16 at 20:50
  • 2
    as mentioned in my Update 2, I found the solution from here. Rounding the \tick made prefix go away. – Milinda Pathirage May 01 '16 at 21:54

0 Answers0