Mathieu aka @miniapeur posted another meme on X (Twitter). It contained a 3D plot of a wavy function. So I did a similar plot, but for roundness and rotational symmetry parametrized it differently so it won’t have these edgy corners.
For a function with rotation symmetry, using polar coordinates gives us smooth edges. We have a custom colormap for a blue gradient, and sorted depth buffering, with pgfplots and TikZ in LaTeX. https://t.co/Fb7wOQayul pic.twitter.com/xPhgfEzNRE
— LaTeX.org (@TeXgallery) February 8, 2025
\documentclass[border=10pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
  axis equal image, ticks=none,
  view={25}{25}, grid,
  zmin = -3, zmax = 3,
  domain     = -pi:pi,
  y domain   = 0:23,
  samples    = 65,
  samples y  = 65,
  colormap   =
    {bluewhite}{color(0cm) = (blue);
    color(1cm) = (white)}]
  \addplot3[surf, z buffer = sort,
    trig format plots = rad]
    ( {y*sin(x) },
      {y*cos(x) },
      {  cos(y) } );
\end{axis}
\end{tikzpicture}
\end{document}See also: Original Source by Stefan Kottwitz
Note: The copyright belongs to the blog author and the blog. For the license, please see the linked original source blog.
Leave a Reply
You must be logged in to post a comment.