
Quiero que el último segmento sea blanco, pero parece que el último segmento está combinado con el segmento anterior.
\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\usepgfplotslibrary{fillbetween}
\pgfmathdeclarefunction{vdw}{0}{\pgfmathparse{8.314*115/(x-0.0000364)-0.1358/x/x}}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis y line = left,
axis x line = bottom,
xlabel = $V$,
ylabel = $P$,
samples = 500,
domain = 0.00005:0.0005,
xmin = 0, xmax = 0.00055,
ymin = 0, ymax = 5*10^6,
]
\addplot[name path=vdw, black, thick, mark=none, ] {vdw};
\addplot[name path=line, gray, no markers, line width=1pt] {2.0*10^6};
\addplot fill between[
of = vdw and line,
split, % calculate segments
every segment no 0/.style={white},
every segment no 1/.style={orange},
every segment no 2/.style={red},
every segment no 3/.style={white},
];
\end{axis}
\end{tikzpicture}
\end{document}
Respuesta1
Para citar del manual PGFPLOTS (Sección 5.6.8Escollos y limitaciones, p.390),
La primera limitación es la escalabilidad. Los algoritmos subyacentes son relativamente ineficientes y escalan mal si el número de muestras es grande. Aplíquelo a tamaños de muestra razonables" y a parcelas con un número razonable de intersecciones". Eso significa: si lleva demasiado tiempo, es posible que deba reducir la densidad de muestreo.
Entonces, si disminuye un poco la cantidad de muestras (imagine su paso con 500 muestras 9x10^{-7}
; demasiado densas), obtendrá resultados correctos. En este caso, he elegido samples = 200
simplemente mediante un enfoque de prueba y error.
\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.3}
\usepgfplotslibrary{fillbetween}
\pgfmathdeclarefunction{vdw}{0}{\pgfmathparse{8.314*115/(x-0.0000364)-0.1358/x/x}}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis y line = left,
axis x line = bottom,
xlabel = $V$,
ylabel = $P$,
samples = 200,
domain = 0.00005:0.0005,
xmin = 0, xmax = 0.00055,
ymin = 0, ymax = 5*10^6,
]
\addplot[name path=vdw, black, thick, mark=none, ] {vdw};
\addplot[name path=line, gray, no markers, line width=1pt] {2.0*10^6};
\addplot fill between[
of = vdw and line,
split, % calculate segments
every segment no 0/.style={white},
every segment no 1/.style={orange},
every segment no 2/.style={red},
every segment no 3/.style={white},
];
\end{axis}
\end{tikzpicture}
\end{document}