"Fill between" 的 pgfplots "Soft clip" 不使用 loglogaxis
pgfplots "Soft clip" of "Fill between" not working with loglogaxis
我在使用 loglogaxis 时很难软剪裁填充。软剪辑域似乎完全关闭了;即设置 soft clip={domain=1:1}
产生与根本没有域相同的结果。
然而域 soft clip={domain=0:10000000000}
导致水平剪辑:
pgfplots 手册没有给出在 loglogaxis 上裁剪的示例,可能是它根本不受支持?如果是,谁能告诉我如何剪辑到 soft clip={domain=3.7E4:5.5E5}
?
我的 MWE:
\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{fillbetween}
\begin{document}
\begin{tikzpicture}
\def\xmin{1E4}
\def\xmax{1E7}
\begin{loglogaxis}[
xmin=\xmin,xmax=\xmax,
ymin=1E-2,ymax=1000,
xlabel={Re [-]},
small,
height=4cm,
width=15cm,
xtick={1E4,1E5,1E6,1E7},
extra x ticks={3.7E4,5.5E5},
extra x tick labels ={3.7E4,5.5E5},
extra x tick style={
tickwidth=\pgfkeysvalueof{/pgfplots/minor tick length},
tick label style={yshift=-0.5mm}
},
ytick={1E-2,1E-1,1,10},
yticklabels={,,1},
extra y ticks={1E-2,1E-1},
grid=major,
domain=1E4:1E7,
]
\def\D{1.4}
\def\yplus{30}
\addplot[name path = C,thick,domain=1E4:1E7] {\yplus/((1/2*(2*log10(x)-0.65)^(-2.3)*(x/\D)^2)^(1/2)/1000)};
\def\yplus{300}
\addplot[name path = D,thick,domain=1E4:1E7] {\yplus/((1/2*(2*log10(x)-0.65)^(-2.3)*(x/\D)^2)^(1/2)/1000)};
\addplot [gray!30] fill between[of=C and D, soft clip={domain=3.7E4:5.5E5}];
\end{loglogaxis}
\end{tikzpicture}%
\end{document}
您可以使用以下技巧对其进行剪辑:
\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{fillbetween}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\def\xmin{1E4}
\def\xmax{1E7}
\begin{loglogaxis}[
xmin=\xmin,xmax=\xmax,
ymin=1E-2,ymax=1000,
xlabel={Re [-]},
small,
height=4cm,
width=15cm,
xtick={1E4,1E5,1E6,1E7},
extra x ticks={3.7E4,5.5E5},
extra x tick labels ={3.7E4,5.5E5},
extra x tick style={
tickwidth=\pgfkeysvalueof{/pgfplots/minor tick length},
tick label style={yshift=-0.5mm}
},
ytick={1E-2,1E-1,1,10},
yticklabels={,,1},
extra y ticks={1E-2,1E-1},
grid=major,
domain=1E4:1E7,
]
\def\D{1.4}
\def\yplus{30}
\addplot[name path = C,thick,domain=1E4:1E7] {\yplus/((1/2*(2*log10(x)-0.65)^(-2.3)*(x/\D)^2)^(1/2)/1000)};
\def\yplus{300}
\addplot[name path = D,thick,domain=1E4:1E7] {\yplus/((1/2*(2*log10(x)-0.65)^(-2.3)*(x/\D)^2)^(1/2)/1000)};
\draw [
help lines,
name path=clippath]
(3.7E4,1E-2) rectangle (5.5E5,1E3);
\addplot [gray!30] fill between[of=C and D,soft clip={clippath}];
\end{loglogaxis}
\end{tikzpicture}%
\end{document}
我在使用 loglogaxis 时很难软剪裁填充。软剪辑域似乎完全关闭了;即设置 soft clip={domain=1:1}
产生与根本没有域相同的结果。
然而域 soft clip={domain=0:10000000000}
导致水平剪辑:
pgfplots 手册没有给出在 loglogaxis 上裁剪的示例,可能是它根本不受支持?如果是,谁能告诉我如何剪辑到 soft clip={domain=3.7E4:5.5E5}
?
我的 MWE:
\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{fillbetween}
\begin{document}
\begin{tikzpicture}
\def\xmin{1E4}
\def\xmax{1E7}
\begin{loglogaxis}[
xmin=\xmin,xmax=\xmax,
ymin=1E-2,ymax=1000,
xlabel={Re [-]},
small,
height=4cm,
width=15cm,
xtick={1E4,1E5,1E6,1E7},
extra x ticks={3.7E4,5.5E5},
extra x tick labels ={3.7E4,5.5E5},
extra x tick style={
tickwidth=\pgfkeysvalueof{/pgfplots/minor tick length},
tick label style={yshift=-0.5mm}
},
ytick={1E-2,1E-1,1,10},
yticklabels={,,1},
extra y ticks={1E-2,1E-1},
grid=major,
domain=1E4:1E7,
]
\def\D{1.4}
\def\yplus{30}
\addplot[name path = C,thick,domain=1E4:1E7] {\yplus/((1/2*(2*log10(x)-0.65)^(-2.3)*(x/\D)^2)^(1/2)/1000)};
\def\yplus{300}
\addplot[name path = D,thick,domain=1E4:1E7] {\yplus/((1/2*(2*log10(x)-0.65)^(-2.3)*(x/\D)^2)^(1/2)/1000)};
\addplot [gray!30] fill between[of=C and D, soft clip={domain=3.7E4:5.5E5}];
\end{loglogaxis}
\end{tikzpicture}%
\end{document}
您可以使用以下技巧对其进行剪辑:
\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{fillbetween}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\def\xmin{1E4}
\def\xmax{1E7}
\begin{loglogaxis}[
xmin=\xmin,xmax=\xmax,
ymin=1E-2,ymax=1000,
xlabel={Re [-]},
small,
height=4cm,
width=15cm,
xtick={1E4,1E5,1E6,1E7},
extra x ticks={3.7E4,5.5E5},
extra x tick labels ={3.7E4,5.5E5},
extra x tick style={
tickwidth=\pgfkeysvalueof{/pgfplots/minor tick length},
tick label style={yshift=-0.5mm}
},
ytick={1E-2,1E-1,1,10},
yticklabels={,,1},
extra y ticks={1E-2,1E-1},
grid=major,
domain=1E4:1E7,
]
\def\D{1.4}
\def\yplus{30}
\addplot[name path = C,thick,domain=1E4:1E7] {\yplus/((1/2*(2*log10(x)-0.65)^(-2.3)*(x/\D)^2)^(1/2)/1000)};
\def\yplus{300}
\addplot[name path = D,thick,domain=1E4:1E7] {\yplus/((1/2*(2*log10(x)-0.65)^(-2.3)*(x/\D)^2)^(1/2)/1000)};
\draw [
help lines,
name path=clippath]
(3.7E4,1E-2) rectangle (5.5E5,1E3);
\addplot [gray!30] fill between[of=C and D,soft clip={clippath}];
\end{loglogaxis}
\end{tikzpicture}%
\end{document}