グループプロットと不連続軸を組み合わせてスケールを変更する

グループプロットと不連続軸を組み合わせてスケールを変更する

連続スケーリングなしで 10% から 50% などへ「ジャンプ」できる、連続していないプロットを作成したいと考えています。 解決策の大部分は自分で得たと思うので、以下に投稿します。 「問題」は、最初のプロット グループを としてymin=0,ymax=6,、2 番目のグループを として定義できないことですymin=45,ymax=80,。 最初の範囲を定義すると、プロットのこの部分が右端に移動し、一部がプロットから外れます (理由はわかりません)。 次の図を参照してください。ここに画像の説明を入力してください 2 番目の範囲を定義すると、プロットは単に「消え」、ドキュメントのこの部分には空白だけが残ります。

現時点では次のようになっています: ここに画像の説明を入力してください 表示したい内容はほぼすべてですが、プロットの「下部」右側には、上部と左下部で高さが異なる 4 本のバーのみ「同じ」高さで表示したいという点が異なります。バーの高さが実際に異なるように見える可能性があり、現在の外観とは異なります。もちろん、上部では、左側のバーは値が小さいため表示されません。

この問題について助けていただければ幸いです

\documentclass{ifacconf}   
\usepackage[round]{natbib} 
\usepackage{graphicx}      
\usepackage{pgfplots}  
\usetikzlibrary{pgfplots.groupplots} 
\usepackage{tikz-timing} 
\usepackage{listings} 
\usepackage{xcolor} 
\definecolor{ForestGreen}{RGB}{34,139,34} 
\definecolor{Gold}{RGB}{218,165,32} 
\definecolor{MediumBlue}{RGB}{25,25,205} 
\usepackage{capt-of} 
\begin{document} 
\pgfplotsset{ 
    every non boxed x axis/.style={}  
    } 
\begin{tikzpicture} 
\begin{groupplot}[
    group style={
        group name=my fancy plots,
        group size=1 by 2,
        xticklabels at=edge bottom,
        vertical sep=0pt
    },
    width=9.5cm,      ybar, 
      enlarge 
      x limits=0.5,
      %ylabel={\#participants}, 
      symbolic x coords={\# Variables (\%),Pipeline Utilization (\%)}, %efficiency
      xtick=data, 
      %nodes near coords,
      %nodes near coords align={vertical}, 
      %every node near coord/.append style={font=\small},
      legend style={at={(0.25,0.69)},anchor=south, cells={align=left}}, ]

\nextgroupplot[%ymin=45,ymax=80,
               ytick={60,80},
               axis x line=top, 
               axis y discontinuity=crunch,
               ybar, 
               bar width=.68cm,
               nodes near coords,
               nodes near coords align={vertical}, 
               every node near coord/.append style={font=\small},
               height=4.5cm]

      \addplot [color=purple, fill = purple,]coordinates {(\# Variables (\%),5.14) (Pipeline Utilization (\%),62.05)}; 
      \addplot [color=orange, fill = orange,]coordinates {(\# Variables (\%),4.91) (Pipeline Utilization (\%),63.53)}; 
      \addplot [color=ForestGreen, fill = ForestGreen,]coordinates {(\# Variables (\%),0.27) (Pipeline Utilization (\%),65.51)}; 
      \addplot [color=MediumBlue, fill = MediumBlue,]coordinates {(\# Variables (\%),0.33) (Pipeline Utilization (\%),66.75)};        

\nextgroupplot[%ymin=0,ymax=6,
               ytick={0},
               axis x line=bottom,
               ybar, 
               bar width=.68cm,
               height=2.0cm]

      \addplot [color=purple, fill = purple,]coordinates {(\# Variables (\%),5.14) (Pipeline Utilization (\%),62.05)}; 
      \addplot [color=orange, fill = orange,]coordinates {(\# Variables (\%),4.91) (Pipeline Utilization (\%),63.53)}; 
      \addplot [color=ForestGreen, fill = ForestGreen,]coordinates {(\# Variables (\%),0.27) (Pipeline Utilization (\%),65.51)}; 
      \addplot [color=MediumBlue, fill = MediumBlue,]coordinates {(\# Variables (\%),0.33) (Pipeline Utilization (\%),66.75)};               
\end{groupplot} 
\end{tikzpicture} 
\end{document}

答え1

あなたのアプローチは折れ線グラフには適していますが、縦棒グラフには適していないと思います。

異なるスケールの 2 つの軸を利用することもできます。

\documentclass{article}   
\usepackage[round]{natbib} 
\usepackage{graphicx}      
\usepackage{pgfplots}
\pgfplotsset{compat=1.14}
\usetikzlibrary{pgfplots.groupplots} 
\usepackage{tikz-timing} 
\usepackage{listings} 
\usepackage{xcolor} 
\definecolor{ForestGreen}{RGB}{34,139,34} 
\definecolor{Gold}{RGB}{218,165,32} 
\definecolor{MediumBlue}{RGB}{25,25,205} 
\usepackage{capt-of} 
\begin{document} 

\begin{tikzpicture} 
\pgfplotsset{
      width=95mm,
      axis x line=box,
      axis y discontinuity=crunch,
      ybar, 
      xmin=0,xmax=1,
      xtick={0,1},
      xticklabels={\# Variables (\%),Pipeline Utilization (\%)}, 
      enlarge x limits=.5,
}

\begin{axis}[%
      ymin=45, ymax=80,
      height=45mm,
      bar width=.68cm,
      ytick={60,80},
      nodes near coords,
      nodes near coords align={vertical}, 
      every node near coord/.append style={font=\small}]

      \addplot [color=purple, fill = purple,] coordinates {(1,62.05)}; 
      \addplot [color=orange, fill = orange,] coordinates {(1,63.53)}; 
      \addplot [color=ForestGreen, fill = ForestGreen,] coordinates {(1,65.51)}; 
      \addplot [color=MediumBlue, fill = MediumBlue,] coordinates {(1,66.75)}; 
\end{axis}

\begin{axis}[%
      ymin=0, ymax=6,
      height=20mm,
      bar width=.68cm,
      ytick={0},
      axis line style={draw=none},
      xticklabels={,},
      nodes near coords,
      nodes near coords align={vertical}, 
      every node near coord/.append style={font=\small}]

      \addplot [color=purple, fill = purple,]coordinates {(0,5.14)}; 
      \addplot [color=orange, fill = orange,]coordinates {(0,4.91)}; 
      \addplot [color=ForestGreen, fill = ForestGreen,]coordinates {(0,0.27)}; 
      \addplot [color=MediumBlue, fill = MediumBlue,]coordinates {(0,0.33)}; 
\end{axis}

\end{tikzpicture} 
\end{document}

ここに画像の説明を入力してください


編集:現時点では、オプションを使用して不連続性クランチをシフトすることはできません。また、軸に装飾を適用すると、特にと をpgfplots使用する場合に問題があるようです。pre lengthpost lengthここそれでも、軸を置き換えるパス置換デコレーションを使用して、カスタムの不連続性クランチを描画できました。残念ながら、axis x line=boxこのソリューションでは使用できないようです。

\documentclass{article}   
\usepackage{pgfplots}
\usetikzlibrary{decorations.pathreplacing}
\pgfplotsset{compat=1.14}
\usepackage{xcolor}
\definecolor{ForestGreen}{RGB}{34,139,34} 
\definecolor{Gold}{RGB}{218,165,32} 
\definecolor{MediumBlue}{RGB}{25,25,205} 

\begin{document} 

\begin{tikzpicture}[discontinuity/.style={decoration={show path construction,lineto code={%
        \path (\tikzinputsegmentfirst) -- (\tikzinputsegmentlast) coordinate[pos=.3] (mid);%
        \draw (\tikzinputsegmentfirst) -- ([yshift=-6pt]mid) -- ++(-3pt,3pt) -- ++(6pt,3pt) -- ++(-3pt,3pt) -- (\tikzinputsegmentlast);%
      }}}]

\pgfplotsset{
      width=95mm,
      axis x line=bottom,
      %axis y discontinuity=crunch,
      ybar, 
      xmin=0,xmax=1,
      xtick={0,1},
      xticklabels={\# Variables (\%),Pipeline Utilization (\%)}, 
      enlarge x limits=.5,
}

\begin{axis}[%
      ymin=45, ymax=80,
      height=45mm,
      bar width=.68cm,
      ytick={60,80},
      nodes near coords,
      nodes near coords align={vertical}, 
      every node near coord/.append style={font=\small},
      every outer y axis line/.append style={discontinuity}
      ]

      \addplot [color=purple, fill = purple,] coordinates {(1,62.05)}; 
      \addplot [color=orange, fill = orange,] coordinates {(1,63.53)}; 
      \addplot [color=ForestGreen, fill = ForestGreen,] coordinates {(1,65.51)}; 
      \addplot [color=MediumBlue, fill = MediumBlue,] coordinates {(1,66.75)}; 
\end{axis}

\begin{axis}[%
      ymin=0, ymax=6,
      height=20mm,
      bar width=.68cm,
      ytick={0},
      axis line style={draw=none},
      tick style={draw=none},
      xticklabels={,},
      nodes near coords,
      nodes near coords align={vertical}, 
      every node near coord/.append style={font=\small}
      ]

      \addplot [color=purple, fill = purple,]coordinates {(0,5.14)}; 
      \addplot [color=orange, fill = orange,]coordinates {(0,4.91)}; 
      \addplot [color=ForestGreen, fill = ForestGreen,]coordinates {(0,0.27)}; 
      \addplot [color=MediumBlue, fill = MediumBlue,]coordinates {(0,0.33)}; 
\end{axis}

\end{tikzpicture} 
\end{document}

ここに画像の説明を入力してください

関連情報