TransWikia.com

PGF interpolated shading from data

TeX - LaTeX Asked on July 30, 2021

Here is the following MWE for a plot with two curves:

documentclass[tikz]{standalone}
usepackage{pgfplots}

pgfplotsset{compat = 1.12}

begin{document}
begin{tikzpicture}
pgfplotsset{
    set layers,
    width=200pt, height=150pt,
    scaled ticks = false,
    scale only axis,
    xmin=-3, xmax=105,
    ymin=1E0, ymax=1E2
}
begin{axis}[
    extra x ticks={},
    extra x tick labels={empty},
    extra x tick style={grid=none},
    extra y ticks={},
    extra y tick labels={(-1.0), (-0.5), (0.5),(1.0)},
    extra y tick style={grid=none},
    yminorticks=true,
]
    addplot [no marks] coordinates {(1, 5) (100, 20)};
    addplot [no marks] coordinates {(1, 10) (100, 80)};
end{axis}
end{tikzpicture}
end{document}

I also have a data file extremes.dat with values corresponding to each horizontal coordinate, e.g.

1,0.2
2,0.3
3,0.1
4,0.9
5,0.4
...
99,0.1
100,0.8

I want to fill the space between the two plots with a shading which is interpolated according to the values in the file to get something like this:
https://i.stack.imgur.com/HZ3gI.png

How can I achieve this? Can it be done in pgfplots and tikz?

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP