1

I want to make a pgfplots histogram to visualize the jitter of a 260 MHz clock signal. I want to use the probability density on the y-Axis. Yet, when I try this, the y-Axis does not display the percentage, nor the number of bin elements.

resulting plot

Here is the code with a few example values:

\documentclass{standalone}
\usepackage{filecontents}
\usepackage{pgfplots,pgfplotstable}
\usepgfplotslibrary{statistics}

\begin{filecontents*}{clk260period.csv}
3.85307942015e-09
3.82802980405e-09
3.84871995265e-09
3.85734095869e-09
3.84800331273e-09
3.83545067472e-09
3.87078519524e-09
3.84597431986e-09
3.82591047015e-09
3.86182286686e-09
3.84048879946e-09
3.83720978908e-09
3.84097879924e-09
3.85360457335e-09
3.83966296654e-09
3.85547204479e-09
3.86168154569e-09
3.83705593078e-09
3.83339948811e-09
3.8636352965e-09
3.83143047443e-09
3.83459532403e-09
3.85677759304e-09
3.85449617442e-09
3.83720978908e-09
3.8672467332e-09
3.84035929045e-09
3.84426447529e-09
3.83784788498e-09
3.85955170352e-09
3.82699015554e-09
3.83593005479e-09
3.86832747192e-09
3.84816852032e-09
3.83753966837e-09
3.86169462912e-09
3.85231149401e-09
3.83668960449e-09
3.83811557696e-09
3.85831377285e-09
3.81494262473e-09
3.84871995265e-09
3.86101865609e-09
3.84432561534e-09
3.83704905172e-09
3.86918681823e-09
3.8509406669e-09
3.8209441231e-09
3.86182286686e-09
3.84630360665e-09
3.83139498189e-09
3.84954137557e-09
3.85072248095e-09
3.83967577434e-09
3.84613397217e-09
3.8710093959e-09
3.8430981029e-09
3.82324510938e-09
3.86516754338e-09
3.84512733977e-09
3.8177953491e-09
3.86233465957e-09
3.85352399329e-09
3.84366402504e-09
3.84496994696e-09
3.8573419675e-09
3.85074404558e-09
3.83685953589e-09
3.85612838163e-09
3.82527488571e-09
3.83149321839e-09
3.86596007496e-09
3.85390991637e-09
3.8279072429e-09
3.86629225025e-09
3.85669588812e-09
3.83772450636e-09
3.83595280452e-09
3.85000075e-09
\end{filecontents*}

\begin{document}
    \begin{tikzpicture}
        \begin{axis}[ybar,ymin=0]
            \addplot +[hist={bins=40,density}] table [y index=0] {clk260period.csv};
        \end{axis}
    \end{tikzpicture}
\end{document}
  • 1
    The density key, according to pgfplots manual, renormalizes the y-values, making the total area of the histogram equal to 1 – LucaD Nov 2 '15 at 14:25
  • So how would I approach this to get the y axis to display the probability of a measurement value falling into each bin without changing the values displayed at the x-Axis? – Higgns Nov 2 '15 at 14:32
1

The y values of the histogram are, by default, the counts in each bin. The density key renormalizes them in a way that the total area of the histogram is 1. I don't know any "automatic" way to have the fractions as y values, but you can apply an y filter to divide the counts by the total number of values (in the case of your example 79). Therefore, the following code should do what you ask for:

\addplot +[hist={bins=40}, y filter/.expression={y/79}] table [y index=0] {clk260period.csv};

I don't know how to avoid hardcoding 79, that is the total number of values.

  • This works for me. I have only three sets of data, so it isn't too much of a hassle. Thanks. – Higgns Nov 2 '15 at 16:28

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.