공통 y축이 있는 여러 pgfplot

공통 y축이 있는 여러 pgfplot

공통 y축이 있는 그래프원고의 일부로 x축과 y축 범위가 동일한 여러 그래프를 그려야 합니다. 나는 tikzpicture와 함께 subflot를 사용하고 있습니다. 제 질문은 두 축의 값 범위가 동일하기 때문에 y축을 제거하고 모든 그래프를 개별 x축과 공통 y축으로 나란히 그릴 수 있다는 것입니다. 각 그래프에는 산점도와 선 도표(실제 데이터와 적합 데이터)가 있습니다. 매뉴얼에는 스택 플롯이 언급되어 있지만 그것은 내가 원하는 것이 아닙니다. 도와주세요.

    \documentclass[3p, dvipsnames]{elsarticle}
    \usepackage{pgfplots,pgfplotstable}
    \usetikzlibrary{plotmarks}
    \pgfplotsset{every  tick/.style={thick,}}
    \pgfkeys{/pgf/number format/set thousands separator = }
    \pgfplotsset{scaled x ticks= true}
    \pgfplotsset{compat=1.13}
    \usepgfplotslibrary{patchplots,colormaps, colorbrewer}
    \usepackage{subfig}
    \usepackage{graphicx}
    %......................................................................................
    \begin{document}
    \begin{figure*}[tb]
        \centering
        \subfloat[][]{
            \begin{tikzpicture}[scale=0.68, font = \large]
\begin{axis}[
            ylabel={$y'$},
            xlabel={$y$},
            ]
            %..............................................................................................................................
            \addplot[mark = none, line width=1.25pt, color =black][domain = 25:350, samples= 50]{(1.114938029*x)+(-16.01)};
            \legend{$\, Y_1$}
            \end{axis}
            \end{tikzpicture}\label{fig:label1}
        }
        \subfloat[][]{
            \begin{tikzpicture}[scale=0.68, font = \large]
            \begin{axis}[
            ylabel={$y'$},
            xlabel={$ y $},
            ]
            %..............................................................................................................................
            \addplot[mark = none, line width=1.25pt, color = RedOrange][domain = 25:350, samples= 50]{(0.96*x)+(5.98)};
            \legend{$\, Y_2$}
            \end{axis}
            \end{tikzpicture}\label{fig:label2}
        }
        \subfloat[][]{
            \begin{tikzpicture}[scale=0.68, font = \large]
            \begin{axis}[
            ylabel={$y'$},
            xlabel={$ y$},
            ]
            %..............................................................................................................................
            \addplot[mark = none, line width=1.25pt, color = Cerulean][domain = 25:350, samples= 50]{(0.96*x)+(6.00)};
            \legend{$\, Y_3$}
            \end{axis}
            \end{tikzpicture}\label{label3}
        }
        \caption{My caption.}\label{figlabel}
    \end{figure*}
    
    \end{document}

답변1

이미지처럼 원하는 경우 더 이상 사용하는 것이 의미가 없습니다 subfig. 이를 수행하는 한 가지 방법은 다음과 같습니다.

\documentclass[tikz, border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\pgfplotsset{legend pos=north west, ymin=-10, ymax=400}
\begin{document}
\begin{tikzpicture}

\begin{axis}[
name=plot1,
ytick pos=left,
xlabel={$y$}, ylabel={$y'$},
]
\addplot[very thick][domain=25:350, samples=2]{(1.114938029*x)+(-16.01)};
\legend{$\, Y_1$}
\end{axis}

\begin{axis}[
name=plot2, at={(plot1.south east)},
ytick=\empty,
xlabel={$y$},
]
\addplot[orange, very thick][domain=25:350, samples=2]{(0.96*x)+(5.98)};
\legend{$\, Y_2$}
\end{axis}

\begin{axis}[
name=plot3, at={(plot2.south east)},
ytick=\empty,
xlabel={$y$},
]
\addplot[teal, very thick][domain=25:350, samples=2]{(0.96*x)+(6.00)};
\legend{$\, Y_3$}
\end{axis}

\end{tikzpicture}
\end{document}

공통 y축이 있는 3개의 연결된 그래프

관련 정보