相图的方位阴影

相图的方位阴影

我想绘制一个相图。如下所示,液相(蓝色)逐渐变为气相(红色)。我想用红色和蓝色之间的方位阴影填充图表的白色部分。

这里已经有一些关于如何制作方位角阴影的解决方案

方位阴影

但我不知道如何将它应用于这个问题。 具体来说,我怎样才能强制方位角阴影仅填充我的图上的空白空间?

代码:

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\usepgfplotslibrary{fillbetween}

\begin{document}
\begin{tikzpicture}

\begin{axis}[xmin=0,ymin=0,xmax=3,ymax=2]
\addplot[name path=gas,very thick] coordinates {(0,0) (1,1) (2,1.5)};
\addplot[name path=liq,very thick] coordinates {(1,1) (1,2.1) (2,2.1)};
\addplot[name path=help1] coordinates {(2,2) (0,2) (0,0)};
\addplot[name path=help2] coordinates {(0,0) (3,0) (3,1.5)};

\addplot[blue] fill between[of=gas and liq];
\addplot[green] fill between[of=liq and help1];
\addplot[red] fill between[of=gas and help2];

\end{axis}

\end{tikzpicture}
\end{document}

在此处输入图片描述

答案1

您可以使用以下方法PGFPlots 方法来自你上一个问题

data cs:polar尽管我们处于笛卡尔坐标系中,我仍然使用键,并使用 移动阴影图shift={(data cs:2,1.5)}。这比使用笛卡尔坐标指定表面图产生了更好的渐变。

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\usepgfplotslibrary{fillbetween}

\begin{document}
\begin{tikzpicture}

\begin{axis}[xmin=0,ymin=0,xmax=3,ymax=2, zmin=0, zmax=2,view={0}{90}, axis equal image]
\addplot3 [
    colormap={redblue}{
        color(0cm)=(red);
        color(0.2cm)=(red!85!blue);
        color(0.4cm)=(red!50!blue);
        color(0.6cm)=(red!15!blue);
        color(1cm)=(blue)},
    surf, shader=interp,
    domain=0:90,
    data cs=polar, 
    y domain=0:2,
    shift={(axis cs:2,1.5)}
] (x,y,x);

\addplot[name path=gas,very thick] coordinates {(0,0) (1,1) (2,1.5)};
\addplot[name path=liq,very thick] coordinates {(1,1) (1,2.1) (2,2.1)};
\addplot[name path=help1] coordinates {(2,2) (0,2) (0,0)};
\addplot[name path=help2] coordinates {(0,0) (3,0) (3,1.5)};

\addplot[blue] fill between[of=gas and liq];
\addplot[green] fill between[of=liq and help1];
\addplot[red] fill between[of=gas and help2];
\end{axis}

\end{tikzpicture}
\end{document}

要使用半对数轴,您可以使用相同的方法,但请注意径向单位现在也是对数的:

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\usepgfplotslibrary{fillbetween}

\begin{document}
\begin{tikzpicture}

\begin{axis}[
    ymode=log,
    xmin=0,
    ymin=1e0,
    xmax=3,
    ymax=1e2,
    zmin=0,
    zmax=2,
    view={0}{90}
]
\addplot3 [
    colormap={redblue}{
        color(0cm)=(red);
        color(0.2cm)=(red!85!blue);
        color(0.4cm)=(red!50!blue);
        color(0.6cm)=(red!15!blue);
        color(1cm)=(blue)},
    surf, shader=interp,
    domain=0:90,
    data cs=polar, 
    y domain=1:10,
    shift={(axis cs:2,32)}
] (x,y,x);

\addplot[name path=gas,very thick] coordinates {(0,1) (1,10) (2,32)};
\addplot[name path=liq,very thick] coordinates {(1,10) (1,126) (2,126)};
\addplot[name path=help1] coordinates {(2,100) (0,100) (0,1)};
\addplot[name path=help2] coordinates {(0,1) (3,1) (3,32)};

\addplot[blue] fill between[of=gas and liq];
\addplot[green] fill between[of=liq and help1];
\addplot[red] fill between[of=gas and help2];
\end{axis}

\end{tikzpicture}
\end{document}

答案2

我在将 Jake 的解决方案应用到我的实际相图中时遇到了问题,但成功地应用了上一个线程中 percusse 的解决方案

方位阴影

它包含了很多我不太理解的后记,但它确实有效随意的区域。

在此处输入图片描述

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\usepgfplotslibrary{fillbetween}

\tikzset{vcol/.code={\colorlet{vcol}{#1}},hcol/.code={\colorlet{hcol}{#1}},vcol=red,hcol=blue}
\pgfdeclarefunctionalshading[vcol,hcol]{azimuth}{\pgfpointorigin}%
{\pgfpoint{50bp}{50bp}}%
{%
\pgfshadecolortorgb{vcol}{\mycola}%
\pgfshadecolortorgb{hcol}{\mycolb}
}{%
atan 90 div dup dup 
\mycolablue \mycolbblue sub mul \mycolablue exch sub 3 1 roll
\mycolagreen \mycolbgreen sub mul \mycolagreen exch sub exch 
\mycolared \mycolbred sub mul \mycolared exch sub 3 1 roll exch 
}

\begin{document}
\begin{tikzpicture}

\begin{semilogyaxis}[xmin=0,ymin=1e0,xmax=3,ymax=1e2,axis on top]

\addplot[name path=gas,very thick] coordinates {(0,1) (1,10) (2,32)};
\addplot[name path=liq,very thick] coordinates {(1,10) (1,126) (2,126)};
\addplot[name path=help1] coordinates {(2,100) (0,100) (0,1)};
\addplot[name path=help2] coordinates {(0,1) (3,1) (3,32)};

\addplot[blue] fill between[of=gas and liq];
\addplot[green] fill between[of=liq and help1];
\addplot[red] fill between[of=gas and help2];
\shade[shading=azimuth,vcol=blue,hcol=red] (axis cs:2,32) rectangle (axis cs:3,100);

\end{semilogyaxis}

\end{tikzpicture}
\end{document}

相关内容