그룹 플롯을 불연속 축과 결합하여 척도 수정

그룹 플롯을 불연속 축과 결합하여 척도 수정

연속적인 크기 조정 없이 10%에서 예를 들어 50%로 "점프"할 수 있는 비연속 플롯을 만들고 싶습니다. 나는 대부분의 솔루션을 직접 얻었고 아래에 게시할 것이라고 생각합니다. "문제"는 첫 번째 플롯 그룹을 으로 정의 ymin=0,ymax=6,하고 두 번째 그룹을 ymin=45,ymax=80,. 첫 번째 범위를 정의하면 플롯의 이 부분이 가장 오른쪽으로 이동하고 그 일부가 플롯에서 벗어납니다(왜인지는 모르겠습니다). 이 사진을 참조하세요:여기에 이미지 설명을 입력하세요 두 번째 범위를 정의하면 플롯이 단순히 "사라지고" 문서의 이 부분에는 공백만 남습니다.

현재 다음과 같습니다. 여기에 이미지 설명을 입력하세요 플롯의 "하단 부분" 오른쪽 부분에 상단 부분과 왼쪽 하단 부분이 다르기 때문에 "동일한" 높이를 가진 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

내 생각에 귀하의 접근 방식은 꺾은선형 차트에 더 적합하지만 열에는 적합하지 않습니다.

스케일이 다른 두 개의 축을 사용할 수 있습니다.

\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 length및 를 사용할 때 축에 장식을 적용할 때 문제가 있는 것 같습니다 .post 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}

여기에 이미지 설명을 입력하세요

관련 정보