3d-gradient-cos.tex 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. \documentclass{article}
  2. \usepackage[pdftex,active,tightpage]{preview}
  3. \setlength\PreviewBorder{2mm}
  4. \usepackage{pgfplots}
  5. \usepgfplotslibrary{patchplots}
  6. \begin{document}
  7. \begin{preview}
  8. \pgfplotsset{
  9. colormap={whitered}{
  10. color(0cm)=(white);
  11. color(1cm)=(orange!75!red)
  12. }
  13. }
  14. \begin{tikzpicture}
  15. \begin{axis}[
  16. colormap name=whitered,
  17. width=15cm,
  18. view={45}{45},
  19. enlargelimits=false,
  20. grid=major,
  21. domain=-90:90,
  22. y domain=-90:90,
  23. % ymode=log,
  24. samples=46, %57 : TeX capacity exceeded, sorry [main memory size=3000000].
  25. % see also http://tex.stackexchange.com/a/7954/5645
  26. % zlabel=f,
  27. %colorbar,
  28. %colorbar style={
  29. % at={(-0.1,0)},
  30. % anchor=south west,
  31. % height=0.25*\pgfkeysvalueof{/pgfplots/parent axis height},
  32. % title={$f(x,y)$}
  33. %}
  34. ]
  35. %\addplot3[patch,patch type=bilinear,mesh,black] {0};
  36. \addplot3[blue,/pgfplots/quiver,
  37. quiver/u=4 * sin(x) * cos(x) * (cos(x)^2 + cos(y)^2),
  38. quiver/v=4 * sin(y) * cos(y) * (cos(x)^2 + cos(y)^2),
  39. quiver/w=0,
  40. quiver/scale arrows=4,
  41. -stealth,samples=15] {-4};
  42. \addplot3[surf,opacity=0.9] {-(cos(x)^2 + cos(y)^2)^2};
  43. \end{axis}
  44. \end{tikzpicture}
  45. \end{preview}
  46. \end{document}