[Tex/LaTex] Plotting Floating point number when changes are very small in data

floating pointtikz-pgf

I want to plot the following data, i am using the CSV file, and pgfplotstable package.

  1. (0,2.42130785530195E-02),
  2. (113.8,2.42130785530195E-02),
  3. (227.6,2.42130781357695E-02),
  4. (341.3,2.42130779271445E-02),
  5. (455.1,2.42130777185196E-02),
  6. (568.9,2.42130775098946E-02),
  7. (682.7,2.42130773012696E-02),
  8. (796.4,2.42130770926447E-02),
  9. (910.2,2.42130768840197E-02),
    1. (1024,2.42130766753947E-02),

enter image description here

I am getting this plot

The Minimal Working Environment :

\documentclass{article}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\usepackage{siunitx}

\begin{document}
\pgfplotstableread[col sep = comma]{lossprob_jin1.csv}\loadedtable

\begin{figure*}
\centering
\begin{tikzpicture}
\begin{axis} [xlabel=Buffer-Size (bits),ylabel=Loss Probability (\%), legend entries = {H=0.6448}]
\addplot table [x=xsw, y=plp, col sep=comma] {\loadedtable} ;
\end{axis}
\end{tikzpicture}
\end{figure*}
\end{document}

Best Answer

Those differences are too small for PGFPlots to handle. You can work around this by subtracting a fixed amount from all numbers using gnuplot and "faking" the labels:

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.12}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
    scaled y ticks=false,
    y tick label style={
        /pgf/number format/fixed,
        /pgf/number format/precision=0
    },
    yticklabel=0.02421307\pgfmathprintnumber{\tick},
    x tick label style={
        /pgf/number format/1000 sep={}
    },
    xlabel=Buffer size in bits,
    ylabel=Loss proabiblity in \%
]
\addplot[raw gnuplot, mark=*] gnuplot {
    plot 'data.dat' using 2:($1-0.02421307)*1e10;
};
\end{axis}
\end{tikzpicture}
\end{document}

But honestly you should probably find some other way to display the effect of the buffer size on the loss probability (are you sure that this effect is even real, or significant?)