1

I want to generate a simple x/y-diagram with data out of a data-table (~ 2000 values).


Minimum Working Example (MWE):

\begin{filecontents}{Data_Table.csv}
X   Y
00:00   0
00:01   50
00:01   100
00:02   150
00:02   200
02:03   250
03:03   300
04:04   350
04:04   400
05:05   450
05:05   500
06:06   550
06:06   600
07:07   700
07:07   800
08:08   900
09:08   1000
12:09   1100
14:09   1200
14:10   1300
15:10   1400
16:11   1500
18:11   1600
20:12   1800
25:00   2000
\end{filecontents}

\documentclass{scrartcl}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\begin{document}

    \begin{figure}
       \begin{tikzpicture}
       \begin{axis}[
       width=0.5\textheight,      
       height=0.5\textheight,
       xlabel={Time [mm:ss]},
       ylabel={Measurement [mm]},
       xtick=data,
       xticklabels from table={Data_Table.csv}{X},
       xticklabel style={rotate=90,anchor=east},
       xmin = 0,
       ymin = 0,
       ymax = 2200,
       legend pos=outer north east,
       legend cell align=left,
       legend style={draw=none}]
       \addplot[color=black,mark=none] table [x expr=\coordindex,y=Y] {Data_Table.csv};
       \legend{Graph}
       \end{axis}
       \end{tikzpicture}
    \end{figure}
\end{document}

Screenshot of the result:

enter image description here


As you can see, there are far too many xticklabels displayed below the x-axis. How can I reduce the quantity (density) of shown xticklabels, e.g. to an interval of 5 minutes?

I think the common xticks={5,10,15}-command won't work because of the inclusion of xticklabels from the data-table (xticklabels from table={Data_Table.csv}{X})...


Thank you very much for your help!

0

1 Answer 1

1

By adding each nth point={some number}too \addplot options you can do what you want. E.g.,:

\addplot[color=black,mark=none, each nth point={2}] table [x expr=\coordindex,y=Y] {Data_Table.csv};

generates the following

enter image description here

6
  • This reduces also the data point density and not only the tick label density, right? Sep 14, 2015 at 10:30
  • @Dr.ManuelKuehner, I believe so. If you put for instance, each nth point={10}, you see that the shape of plot changes as well, hence, actual data is being reduced in frequency.
    – Pouya
    Sep 14, 2015 at 11:05
  • Ok. I think that the question is about the tick labels density independent from the data density. Sep 14, 2015 at 12:38
  • @Dr.ManuelKuehner, you are indeed right! I might remove the answer...
    – Pouya
    Sep 14, 2015 at 12:41
  • Let's wait what Dave has to say :) Sep 14, 2015 at 12:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .