1

I have a 3d graph which has a 'small' bump in the middle of it that is quite hard to notice due to the shading. I was wondering if it would be possible to make it so that the change in the colour of the shading is more dramatic (i.e it goes from blue to red faster). If not then perhaps changing the order of the shading (red --> low, blue --> high) so it is more noticeable, thanks.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots}
\usepackage{tikz}

\newcommand{\plotpotential}[2]{
\begin{axis}[view={70}{70}]
\addplot3[surf,shader=flat, draw=black, z buffer=sort, samples=30,domain=-400:400]
{-3933.8*(x^2+y^2)+0.0325*(x^2+y^2)^2};
\end{axis}
}


\begin{document}
\begin{figure}
\begin{tikzpicture} 
    {\plotpotential{\polangle}{\azangle}};
\end{tikzpicture}
\end{figure}
\end{document}

1 Answers1

1

It certainly is possible, there are many many examples for colormaps in the pgfplots manual. Here is a hot variant. ;-)

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots}
\usepackage{tikz}
\pgfplotsset{compat=1.15,
%/pgfplots/colormap={blue}{rgb255(0)=(255,255,0) rgb255(10)=(255,0,255)}
}


\newcommand{\plotpotential}[2]{
\begin{axis}[view={70}{70},colormap/hot]
\addplot3[surf,shader=flat, draw=black, z buffer=sort, samples=30,domain=-400:400]
{-3933.8*(x^2+y^2)+0.0325*(x^2+y^2)^2};
\end{axis}
}


\begin{document}
\begin{figure}
\begin{tikzpicture} 
    {\plotpotential{\polangle}{\azangle}};
\end{tikzpicture}
\end{figure}
\end{document}

enter image description here

If that's not drastic enough for you, you can always define your own color map as described in section 4.7.6 of the manual.

  • Thanks a bunch, that colormap line should be really useful :) – Jordan Abbott Jan 25 '18 at 18:22
  • @CooperCape I think that the main reason why you want to do that is that the corners are quite high. You may thus want to draw a polar plot, along the lines of the second plot on p. 169 of the pgfplots manual. When it comes to this Mexican hat shape, I personally like the asymptote solutions more appealing. –  Jan 25 '18 at 18:34