![여러 색상의 yaxis pgfplot의 축 도움말을 가리키는 단순화 및 원](https://rvso.com/image/405348/%EC%97%AC%EB%9F%AC%20%EC%83%89%EC%83%81%EC%9D%98%20yaxis%20pgfplot%EC%9D%98%20%EC%B6%95%20%EB%8F%84%EC%9B%80%EB%A7%90%EC%9D%84%20%EA%B0%80%EB%A6%AC%ED%82%A4%EB%8A%94%20%EB%8B%A8%EC%88%9C%ED%99%94%20%EB%B0%8F%20%EC%9B%90.png)
내가 원하는 방식으로 아래 플롯을 생성했습니다.
이것을 단순화할 수 있나요?
그러나 x축을 검정색으로 유지하면서 y축, 레이블 및 눈금 레이블을 색칠하는 것이 매우 복잡하다는 것을 알았습니다. 축의 색상 스타일 설정이 특히 나쁜 것 같습니다.
y axis line style = {mycolor2},
y axis line style = {mycolor2},
y tick label style= {mycolor2},
y tick style= {mycolor2},
ylabel style = {mycolor2},
이 작업을 수행할 수 있는 더 간단한 방법이 있나요?
선 주위에 원을 그리는 방법
또한 연결된 축을 가리키는 각 선 주위에 원을 표시하고 싶습니다. 어떻게 하는 것이 가장 좋습니까?
MWE
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.5}
\begin{document}
% This file was created by matlab2tikz.
\definecolor{mycolor1}{rgb}{0.00000,0.44700,0.74100}%
\definecolor{mycolor2}{rgb}{0.85000,0.32500,0.09800}%
%
\begin{tikzpicture}
\begin{axis}[%
width=(\hsize/2),
height=(\hsize/2),
at={(0.2in,0.444in)},
scale only axis,
xmin=0,
xmax=0.5,
xlabel near ticks,
xlabel={Density $\lambda$},
ymin=0,
ymax=0.00035,
ylabel near ticks,
ylabel={Rate, ($s^{-1}$)},
axis x line*=bottom,
axis y line*=left,
y axis line style = {mycolor1},
y axis line style = {mycolor1},
y tick label style= {mycolor1},
y tick style= {mycolor1},
ylabel style = {mycolor1},
xmajorgrids,
ymajorgrids,
legend style={legend cell align=left, align=left, draw=white!15!black}
]
\addplot [color=mycolor1, mark=o, mark options={solid, mycolor1}]
table[row sep=crcr]{%
1e-05 0.000349984346613178\\
0.0250095 0.000294763280950208\\
0.100008 0.000223262905327838\\
0.1750065 0.000189761632377871\\
0.250005 0.000168814588345592\\
0.3250035 0.000153988764794569\\
0.400002 0.000142726344312675\\
0.4750005 0.000133766561301556\\
0.5 0.000131160050335831\\
};\label{rate_plot}
\addlegendentry{Rate}
\end{axis}
\begin{axis}[%
width=(\hsize/2),
height=(\hsize/2),
at={(0.2in,0.444in)},
scale only axis,
xmin=0,
xmax=0.5,
ymin=0,
ymax=0.00035,
ylabel near ticks,
ylabel={Rate 2, ($s^{-1}$)},
hide x axis,
axis y line*= right,
y axis line style = {mycolor2},
y axis line style = {mycolor2},
y tick label style= {mycolor2},
y tick style= {mycolor2},
ylabel style = {mycolor2},
xmajorgrids,
ymajorgrids,
legend style={legend cell align=left, align=left, draw=black, text=black}
]
\addlegendimage{/pgfplots/refstyle=rate_plot}\addlegendentry{Rate}
\addplot [color=mycolor2, mark=o, mark options={solid, mycolor2}]
table[row sep=crcr]{%
1e-05 0.00016332275313237\\
0.0250095 0.000115848009059579\\
0.100008 6.64661750163849e-05\\
0.1750065 4.80196831721179e-05\\
0.250005 3.80067958197952e-05\\
0.3250035 3.16272652493933e-05\\
0.400002 2.71728300947399e-05\\
0.4750005 2.38707996203775e-05\\
0.5 2.29503949117285e-05\\
};
\addlegendentry{Rate 2}
\end{axis}
\end{tikzpicture}%
\end{document}
이미 사용된 게시물
답변1
이에 대한 스타일을 정의할 수 있습니다.
\pgfplotsset{yaxis stuff style/.style={y axis line style = {#1},
y tick label style= {#1},
y tick style= {#1},
ylabel style = {#1},
}}
두 축에서 사용합니다.
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\pgfplotsset{yaxis stuff style/.style={y axis line style = {#1},
y tick label style= {#1},
y tick style= {#1},
ylabel style = {#1},
}}
\begin{document}
% This file was created by matlab2tikz.
\definecolor{mycolor1}{rgb}{0.00000,0.44700,0.74100}%
\definecolor{mycolor2}{rgb}{0.85000,0.32500,0.09800}%
%
\begin{tikzpicture}
\begin{axis}[%
width=(\hsize/2),
height=(\hsize/2),
at={(0.2in,0.444in)},
scale only axis,
xmin=0,
xmax=0.5,
xlabel near ticks,
xlabel={Density $\lambda$},
ymin=0,
ymax=0.00035,
ylabel near ticks,
ylabel={Rate, ($s^{-1}$)},
axis x line*=bottom,
axis y line*=left,
yaxis stuff style = {mycolor1},
xmajorgrids,
ymajorgrids,
legend style={legend cell align=left, align=left, draw=white!15!black}
]
\addplot [color=mycolor1, mark=o, mark options={solid, mycolor1}]
table[row sep=crcr]{%
1e-05 0.000349984346613178\\
0.0250095 0.000294763280950208\\
0.100008 0.000223262905327838\\
0.1750065 0.000189761632377871\\
0.250005 0.000168814588345592\\
0.3250035 0.000153988764794569\\
0.400002 0.000142726344312675\\
0.4750005 0.000133766561301556\\
0.5 0.000131160050335831\\
};\label{rate_plot}
\addlegendentry{Rate}
\end{axis}
\begin{axis}[%
width=(\hsize/2),
height=(\hsize/2),
at={(0.2in,0.444in)},
scale only axis,
xmin=0,
xmax=0.5,
ymin=0,
ymax=0.00035,
ylabel near ticks,
ylabel={Rate 2, ($s^{-1}$)},
hide x axis,
axis y line*= right,
yaxis stuff style = {mycolor2},
xmajorgrids,
ymajorgrids,
legend style={legend cell align=left, align=left, draw=black, text=black}
]
\addlegendimage{/pgfplots/refstyle=rate_plot}\addlegendentry{Rate}
\addplot [color=mycolor2, mark=o, mark options={solid, mycolor2}]
table[row sep=crcr]{%
1e-05 0.00016332275313237\\
0.0250095 0.000115848009059579\\
0.100008 6.64661750163849e-05\\
0.1750065 4.80196831721179e-05\\
0.250005 3.80067958197952e-05\\
0.3250035 3.16272652493933e-05\\
0.400002 2.71728300947399e-05\\
0.4750005 2.38707996203775e-05\\
0.5 2.29503949117285e-05\\
};
\addlegendentry{Rate 2}
\end{axis}
\end{tikzpicture}%
\end{document}
원칙적으로 해당 축 앞에 \color{mycolor1}
및 만 추가할 수 있습니다.\color{mycolor2}
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
% This file was created by matlab2tikz.
\definecolor{mycolor1}{rgb}{0.00000,0.44700,0.74100}%
\definecolor{mycolor2}{rgb}{0.85000,0.32500,0.09800}%
%
\begin{tikzpicture}
\color{mycolor1}
\begin{axis}[%
width=(\hsize/2),
height=(\hsize/2),
at={(0.2in,0.444in)},
scale only axis,
xmin=0,
xmax=0.5,
xlabel near ticks,
xlabel={Density $\lambda$},
ymin=0,
ymax=0.00035,
ylabel near ticks,
ylabel={Rate, ($s^{-1}$)},
axis x line*=bottom,
axis y line*=left,
xmajorgrids,
ymajorgrids,
legend style={legend cell align=left, align=left, draw=white!15!black}
]
\addplot [color=mycolor1, mark=o, mark options={solid, mycolor1}]
table[row sep=crcr]{%
1e-05 0.000349984346613178\\
0.0250095 0.000294763280950208\\
0.100008 0.000223262905327838\\
0.1750065 0.000189761632377871\\
0.250005 0.000168814588345592\\
0.3250035 0.000153988764794569\\
0.400002 0.000142726344312675\\
0.4750005 0.000133766561301556\\
0.5 0.000131160050335831\\
};\label{rate_plot}
\addlegendentry{Rate}
\end{axis}
\color{mycolor2}
\begin{axis}[%
width=(\hsize/2),
height=(\hsize/2),
at={(0.2in,0.444in)},
scale only axis,
xmin=0,
xmax=0.5,
ymin=0,
ymax=0.00035,
ylabel near ticks,
ylabel={Rate 2, ($s^{-1}$)},
hide x axis,
axis y line*= right,
xmajorgrids,
ymajorgrids,
legend style={legend cell align=left, align=left, draw=black, text=black}
]
\addlegendimage{/pgfplots/refstyle=rate_plot}\addlegendentry{Rate}
\addplot [color=mycolor2, mark=o, mark options={solid, mycolor2}]
table[row sep=crcr]{%
1e-05 0.00016332275313237\\
0.0250095 0.000115848009059579\\
0.100008 6.64661750163849e-05\\
0.1750065 4.80196831721179e-05\\
0.250005 3.80067958197952e-05\\
0.3250035 3.16272652493933e-05\\
0.400002 2.71728300947399e-05\\
0.4750005 2.38707996203775e-05\\
0.5 2.29503949117285e-05\\
};
\addlegendentry{Rate 2}
\end{axis}
\end{tikzpicture}%
\end{document}
그러나 나는 그것을 권장하지 않습니다.