2

I want to display an interference pattern with pgfplots and \addplot3. The idea is to draw the surface I(x,y)=(1+V*cos(x)) and to show the influence of the visibility factor (V) on the pattern. For a bad visibility (V=0.15 for example) the contrast should be bad, but that's not what I obtain.

bad pattern

Here's the TikZ code:

\documentclass{article}
\usepackage{pgfplots}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[]
\begin{axis}[
name=plot1,
width=10cm, 
height=3cm,
xmin=-12, xmax=12,
ymin=0,ymax=2.5,
samples=50,
axis lines=middle,
inner axis line style={=>},
xlabel={$\phi$},
ylabel={$I/I_0$},
xlabel style={anchor=west},
ylabel style={anchor=south},
xtick=\empty,
ytick={1,2},
]
\addplot[domain=-12:12]{1+.15*cos(deg(x))};
\end{axis}
\begin{axis}[name=plot2,at={($(plot1.south)+(0,-2mm)$)},anchor=north,colormap/blackwhite,view={0}{90},width=10cm,height=2cm,xmin=-12, xmax=12,ymin=0, ymax=2,samples=50,hide axis]
\addplot3[domain=-12:12, surf,shader=interp]{1+.15*cos(deg(x))};
\end{axis}
\end{tikzpicture}
\end{document}

Any idea?

diabonas
  • 25,784
  • This is the same problem as in Scaling colormaps with pgfplots: by default, the colour map is scaled so that lowest value of your data is mapped to black and the highest value is mapped to white, so changing the function values does not change the colouring at all, as the colouring is adapted as well. You need to set the desired range of the colouring explicitly by using ...,colormap/blackwhite,point meta min=0,point meta max=2,... in the optional argument of \begin{axis}. – diabonas Oct 13 '17 at 17:30

0 Answers0