1

so I'm working on a graph in pgfplots and in my data there is are a few outliers as you can see hereenter image description here

so I was wondering how can I break the y axis as to enlarge the difference between the other 3 values. similar to this enter code here

Here my code so far

    \begin{tikzpicture}
        \begin{axis} [ylabel=$T_{pdr}/s$,xlabel=Transition$/ps$,legend pos=outer north east]
        \addlegendentry{$\mathrm{C}_{inv}$}
        \addplot table [x=Transition,y=tpdr,col sep = tab] {./data/complex/size1/cin1.csv};
        \addlegendentry{$2\mathrm{C}_{inv}$}
        \addplot table [x=Transition,y=tpdr,col sep = tab] {./data/complex/size1/cin2.csv};
        \addlegendentry{$4\mathrm{C}_{inv}$}
        \addplot table [x=Transition,y=tpdr,col sep = tab] {./data/complex/size1/cin4.csv};
        \addlegendentry{$8\mathrm{C}_{inv}$}
        \addplot table [x=Transition,y=tpdr,col sep = tab] {./data/complex/size1/cin8.csv};
        \end{axis}
    \end{tikzpicture}
  • 1
    Hi, welcome. You could use a groupplot as in https://tex.stackexchange.com/a/62778/ Edit: see also https://tex.stackexchange.com/q/359878/ – Torbjørn T. Apr 18 '20 at 20:45
  • 1
    Welcome! You will get better and more timely help if you post a complete minimal working example. I guess besides you not many users will have the data files you are using. You can use coordinate transformations to get the effect. (@TorbjørnT. Are you sure this post works also if the individual plots go in both or all three ranges?) –  Apr 18 '20 at 20:45
  • @Schrödinger'scat On second thought, no. Didn't really think that one through ... (Abdelsalam: ignore at least my first link.) – Torbjørn T. Apr 18 '20 at 20:51
  • Just looking at the plot I think there is a good chance that ymode=log will do the trick. –  Apr 18 '20 at 20:55

1 Answers1

1

This is how you can do it to line chart.

\documentclass{minimal}  
\usepackage{tikz}
\usepackage{pgfplots}
\tikzset{
    axis break gap/.initial=0mm
}

\begin{document}

\begin{tikzpicture} \begin{axis}[ name=bottom axis,
legend cell align=left, width=14.3cm, height=4cm, xlabel = {X axis}, xmin = 0, xmax = 10, % Updated x-axis ranges for the bottom axis ymin = 38.5, ymax = 40.5, % Updated y-axis ranges for the bottom axis ytick={38,39,40,41,42,43}, % Adjusted y-axis ticks grid = major, axis x line*=bottom, legend pos=south east, ] \addplot[ color=blue, mark=o, ] coordinates { (1,74.05929323)(2,74.11004875)(3,73.83395062)(4,74.1121437)(5,74.04318766)(6,74.19709055)(7,74.08991301)(8,74.14607895)(9,74.20123279) }; %\addlegendentry{Parameter1}

\addplot[ color=red, mark=triangle, ] coordinates { (1,73.90355191)(2,73.90355191)(3,73.90355191)(4,73.90355191)(5,73.90355191)(6,74.02102892)(7,74.01695258)(8,73.9599083)(9,73.96268008) }; %\addlegendentry{Parameter2}

\addplot[ color=green, mark=square, ] coordinates { (1,73.90355191)(2,73.90355191)(3,73.90355191)(4,73.90355191)(5,73.90355191)(6,74.21653139)(7,74.27160398)(8,74.34418505)(9,74.15820202) }; %\addlegendentry{Parameter3}

\addplot[ color=purple, mark=star, ] coordinates { (1,70.78359818)(2,70.82715427)(3,70.88941587)(4,70.86594118)(5,70.72003935)(6,73.98564562)(7,73.87784185)(8,73.81499949)(9,73.91649512) }; %\addlegendentry{Parameter4}

\addplot[ color=orange, mark=diamond, ] coordinates { (1,73.90355191)(2,73.90355191)(3,73.90355191)(4,73.90355191)(5,73.90355191)(6,73.10161425)(7,72.99986002)(8,72.80970372)(9,72.39335599) }; %\addlegendentry{Parameter5}

\addplot[ color=brown, mark=asterisk, ] coordinates { (1,73.90355191)(2,73.90355191)(3,73.90355191)(4,73.90355191)(5,73.90355191)(6,73.7151607)(7,73.54188442)(8,73.65497217)(9,73.67833404) }; %\addlegendentry{Parameter6}

\addplot[ color=cyan, mark=oplus, ] coordinates { (1,39.37007874)(2,39.37007874)(3,39.37007874)(4,39.37007874)(5,39.37007874)(6,45.5)(7,73.7824888)(8,73.72328176)(9,73.75368027) }; %\addlegendentry{Parameter7}

\end{axis}

\begin{axis}[ at=(bottom axis.north), anchor=south, yshift=\pgfkeysvalueof{/tikz/axis break gap}, width=14.3cm, height=10cm, xmin = 0, xmax = 10, % Updated x-axis ranges for the top axis ymin = 69, ymax = 75, % Updated y-axis ranges for the top axis ytick={70,71,72,73,74,80}, % Adjusted y-axis ticks grid = major, ylabel = {Y axis}, title = {Caption}, % Added title (topic) title style={yshift=-1ex, text centered}, % Center the title %legend entries = {excitatiespectrum}, axis x line*=top, legend pos=south east, legend cell align=left, xticklabel=\empty, after end axis/.code={ \draw (rel axis cs:0,0) +(-2mm,-1mm) -- +(2mm,1mm) ++(0pt,-\pgfkeysvalueof{/tikz/axis break gap}) +(-2mm,-1mm) -- +(2mm,1mm) (rel axis cs:0,0) +(0mm,0mm) -- +(0mm,0mm) ++(0pt,-\pgfkeysvalueof{/tikz/axis break gap}) +(-2mm,-1mm) -- +(2mm,1mm); \draw (rel axis cs:0,0) +(-2mm,0mm) -- +(2mm,2mm) ++(0pt,-\pgfkeysvalueof{/tikz/axis break gap}) +(-2mm,-1mm) -- +(2mm,1mm) (rel axis cs:0,0) +(0mm,0mm) -- +(0mm,0mm) ++(0pt,-\pgfkeysvalueof{/tikz/axis break gap}) +(-2mm,-1mm) -- +(2mm,1mm); }]

\addplot[ color=blue, mark=o, ] coordinates { (1,74.05929323)(2,74.11004875)(3,73.83395062)(4,74.1121437)(5,74.04318766)(6,74.19709055)(7,74.08991301)(8,74.14607895)(9,74.20123279) }; \addlegendentry{Parameter1}

\addplot[ color=red, mark=triangle, ] coordinates { (1,73.90355191)(2,73.90355191)(3,73.90355191)(4,73.90355191)(5,73.90355191)(6,74.02102892)(7,74.01695258)(8,73.9599083)(9,73.96268008) }; \addlegendentry{Parameter2}

\addplot[ color=green, mark=square, ] coordinates { (1,73.90355191)(2,73.90355191)(3,73.90355191)(4,73.90355191)(5,73.90355191)(6,74.21653139)(7,74.27160398)(8,74.34418505)(9,74.15820202) }; \addlegendentry{Parameter3}

\addplot[ color=purple, mark=star, ] coordinates { (1,70.78359818)(2,70.82715427)(3,70.88941587)(4,70.86594118)(5,70.72003935)(6,73.98564562)(7,73.87784185)(8,73.81499949)(9,73.91649512) }; \addlegendentry{Parameter4}

\addplot[ color=orange, mark=diamond, ] coordinates { (1,73.90355191)(2,73.90355191)(3,73.90355191)(4,73.90355191)(5,73.90355191)(6,73.10161425)(7,72.99986002)(8,72.80970372)(9,72.39335599) }; \addlegendentry{Parameter5}

\addplot[ color=brown, mark=asterisk, ] coordinates { (1,73.90355191)(2,73.90355191)(3,73.90355191)(4,73.90355191)(5,73.90355191)(6,73.7151607)(7,73.54188442)(8,73.65497217)(9,73.67833404) }; \addlegendentry{Parameter6}

\addplot[ color=cyan, mark=oplus, ] coordinates { (1,39.37007874)(2,39.37007874)(3,39.37007874)(4,39.37007874)(5,67.9)(6,73.91158176)(7,73.7824888)(8,73.72328176)(9,73.75368027) }; \addlegendentry{Parameter7} \end{axis} \end{tikzpicture}

\end{document}

Then download the generated PDF file and upload it to the original location of the main text file. And there you can add following code to generate high-quality image:

\begin{figure*}
\center
\includegraphics[scale=0.8, trim={3cm 16.5cm 4.5cm 2.2cm},clip]{Generated_Plot1.pdf }  
% trim from right edge
%\includegraphics[trim={0 0 5cm 0},clip]{SMOTE.pdf}
\caption{\label{schema}Caption 1}
\label{fig}
\end{figure*}

enter image description here

Finally you can see a continuous curve.