【问题标题】:pgfplots "Soft clip" of "Fill between" not working with loglogaxis“填充之间”的pgfplots“软剪辑”不适用于loglogaxis
【发布时间】:2021-12-04 10:24:23
【问题描述】:

在使用对数轴时,我正在努力软剪裁填充。软剪辑域似乎完全关闭了;即设置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}

【问题讨论】:

    标签: latex fill clip tikz pgfplots


    【解决方案1】:

    您可以使用以下技术对其进行剪辑:

    \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}
    

    【讨论】:

    • 感谢这个解决方案(并将图片放在里面;我还不允许)!如果有人可以向我解释为什么使用域的“自然”软剪辑不起作用,我会稍等一下;如果您的解决方案是唯一的可能性,我会将其标记为答案。再次感谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-14
    • 1970-01-01
    • 2017-02-01
    • 2015-08-12
    • 1970-01-01
    相关资源
    最近更新 更多