2

I was wondering whether it is possible to make a plot with x (or y) axis containing one of the shapes below indicating that x axis is not starting from zero?

Could we make the curves also with the points on the table below?

enter image description here

enter image description here

    \documentclass[tikz]{article}
\usepackage{pgfplots}
\usepackage{pgfplotstable} % For \pgfplotstableread

\pgfplotstableread{
100     35
55  30
}\datatablea

\pgfplotstableread{
55  20
100 21
}\datatableb

\pgfplotstableread{
55  50
100 56
}\datatablec
\begin{document}
\begin{tikzpicture}
\begin{axis}[xmin=16,axis y discontinuity=crunch]
\addplot table  {\datatablea};
\addplot table  {\datatableb};
\addplot table  {\datatablec};
\end{axis}
\end{tikzpicture}
\end{document}

The desired figure: enter image description here

Y_gr
  • 3,322
  • 3
    Two examples using crunch symbol with pgfplots: http://tex.stackexchange.com/questions/79269/how-to-show-the-data-does-not-start-at-zero-symbol-on-a-pgfplot-graph/79272#79272, http://tex.stackexchange.com/questions/84229/discontinuity-of-log-axis-in-pgfplots – Ignasi Nov 11 '16 at 10:57
  • 1
    Multiple "crunches" as in your example can be obtained by using three axes (e.g. via a groupplot), as in http://tex.stackexchange.com/questions/46422/axis-break-in-pgfplots – Torbjørn T. Nov 20 '16 at 03:04

1 Answers1

1

output of code

\documentclass[border=5mm]{standalone}
\usepackage{amsmath}
\usepackage{pgfplotstable} % For \pgfplotstablereadm also loads pgfplots
\usepgfplotslibrary{groupplots}
\pgfplotsset{compat=1.15}
\pgfplotstableread{
55  20
100 21
}\datatablea

\pgfplotstableread{
55  30
100     35
}\datatableb

\pgfplotstableread{
55  50
100 56
}\datatablec
\begin{document}
\begin{tikzpicture}
\begin{groupplot}[
  group style={
    % set number of axes, columns by rows
    group size=3 by 1,
    % we don't want any gap between axes
    horizontal sep=0pt
  },
  % the following settings apply to all three axes
  ymin=0,ymax=110,
  axis lines=middle,
  enlarge x limits=0.2,
  width=5cm,
  height=5cm,
  scale only axis,
  axis x discontinuity=crunch,
  xtick=data,
  ytick=data,
  longlines/.style={
    shorten >=-5mm,
    shorten <=-5mm
  },
  clip=false
]

% \nextgroupplot starts a new axis
\nextgroupplot[
  x axis line style={-}, % remove arrow tip
  width=2cm, % make this narrower
  xmin=19,
  ylabel=$P$
]

\addplot +[longlines] table[x index=1,y index=0]  {\datatablea}
node [above left, black] {$S_B$}
;
\coordinate (a100) at (\pgfkeysvalueof{/pgfplots/xmin},100);
\coordinate (a55) at (\pgfkeysvalueof{/pgfplots/xmin},55);

% plot vertical dashed lines
\addplot [ycomb,dashed,mark=none] table[x index=1,y index=0]  {\datatablea};


\nextgroupplot[
 hide y axis,  % don't want y-axis here
 x axis line style={-}
]

\addplot +[longlines] table[x index=1,y index=0]  {\datatableb}
node [above left, black] {$S_A$}
;

\addplot [ycomb,dashed,mark=none] table[x index=1,y index=0]  {\datatableb};

\nextgroupplot[
  hide y axis,
  xlabel={$Q_S$}
]

\addplot +[longlines] table[x index=1,y index=0]  {\datatablec}
coordinate [pos=0] (3a)
coordinate [pos=1] (3b)
node [above left, black] {$S_{\text{something}}$}
;

\addplot [ycomb,dashed,mark=none] table[x index=1,y index=0]  {\datatablec};
\end{groupplot}

% draw horizontal dashed lines
\draw [dashed] (a100) -- (3b);
\draw [dashed] (a55) -- (3a);

\end{tikzpicture}
\end{document}
Torbjørn T.
  • 206,688