2

I am trying to plot a bar chart with pgfplots. However, I would like to show the outliers with scale breaks in excel, similarly like this (retrieved from here):

example

The code that I end up with while trying to achieve this, currently is:

\documentclass[11pt]{article}

\begin{filecontents*}{data.csv}
range,a
2, 0.028
3, 0.0
4, 0.001
5, 0.0
67, 0.01
68, 0.009
69, 0.012
70, 0.021
71, 0.039
72, 0.054
73, 0.073
74, 0.09
75, 0.133
76, 0.151
77, 0.244
78, 0.27
79, 0.377
80, 0.48
81, 0.508
82, 0.605
83, 0.846
84, 1.012
85, 1.193
86, 1.387
87, 1.54
88, 1.569
89, 1.907
90, 1.933
91, 1.902
92, 1.931
93, 1.748
94, 1.633
95, 1.356
96, 1.145
97, 0.886
98, 0.688
99, 0.432
100, 0.2
101, 0.17
102, 0.09
103, 0.04
104, 0.03
105, 0.0
106, 0.01
107, 0.01
108, 0.01
\end{filecontents*}

\usepackage{pgfplots}
\usepackage{pgfplots,pgfplotstable}

\pgfplotstableread[col sep=comma]{data.csv}\results

\begin{document}

\begin{figure}[]
\centering  
  \begin{center}
            \begin{tikzpicture}[scale=0.55]
            \begin{axis} [xlabel={}, 
            ylabel={},
            clip=false,
            axis x line*=bottom,
            ymin=0,
            axis y line*=left,
            xmin=0,
            ymax=10,
            legend pos=north east,
            ybar =0,
            xtick distance={20},
            bar width=1,
            xtick distance={20},
            ytick distance={2},
            restrict x to domain*=0:140,
            restrict y to domain*=0:10,
            extra y ticks={10},
            extra y tick style={grid=major},
            ]

            \addplot+[orange] table[x=range, y=a, col sep=comma] \results;
            \legend{Data}

            \node [above] at (axis cs: 25,8.9) {\textbf{$=$\pgfplotstablegetelem{0}{a}\of\results
                \pgfplotsretval}};

            \end{axis}
            \end{tikzpicture}   
  \end{center}
\end{figure}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.