TikZ:绘制不同形状的lp-Norm

TikZ:绘制不同形状的lp-Norm

我正在尝试使用 Ti 重现下面的图片Z。

在此处输入图片描述

已经有人问过类似的问题这里,但我无法将这些答案应用到我的问题中,因为我需要完全相同的图片,而不仅仅是形状。我尝试修改给出的答案,但这并没有带来任何有用的结果,因为我不太理解,pgfplots而且我对 Ti 还比较陌生Z ...

这就是我迄今为止所做的。

\begin{tikzpicture}
   \foreach \x in {0,4.5,9,13.5}{
      \draw [->] (-1.2-\x,0)--(2.5-\x,0);
      \draw [->] (0-\x,-1.2)--(0-\x,1.7);
      \draw[shorten <=-1cm, shorten >=-3mm] (0-\x,1)--(2-\x,0) node [midway, above] {$A$};
   }

   \draw[blue] (-10,0)--(-9,1)--(-8,0)--(-9,-1)--cycle;
   \draw [blue](-4.5,0) circle (0.88cm);

   \foreach \x in {0.66}{
      \draw[blue] (-\x,-\x)--(-\x,\x)--(\x,\x)--(\x,-\x)--cycle;
   }

   \draw[blue,scale=1,domain=0:90,samples=100,smooth,variable=\t]
      plot({-1*cos(\t)^(3)-13.5},{1*sin(\t)^(3)});
   \draw[blue,scale=1,domain=0:90,samples=100,smooth,variable=\t]
      plot({-1*cos(\t)^(3)-13.5},{-1*sin(\t)^(3)});
   \draw[blue,scale=1,domain=0:90,samples=100,smooth,variable=\t]
      plot({1*cos(\t)^(3)-13.5},{-1*sin(\t)^(3)});
   \draw[blue,scale=1,domain=0:90,samples=100,smooth,variable=\t]
      plot({1*cos(\t)^(3)-13.5},{1*sin(\t)^(3)});                 

\end{tikzpicture}

下面的图片显示了结果。代码很糟糕,但这是我现在能想到的最好的代码了……

p=2/3,1,2,infty 的 p 范数

答案1

可能是这样的吗?它可能不是最高效的,因为我从问题中的代码开始,而绘制每个代码可能会提供更大的优雅。

\documentclass[border=10pt,multi,tikz]{standalone}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{tikzpicture}[>=Stealth]
   \foreach \i in {0,...,3}{
     \begin{scope}[xshift=\i*4.5cm]
      \draw [<->] (-1.2,0)--(2.5,0);
      \draw [<->] (0,-1.2)--(0,1.7);
      \draw[shorten <=-1cm, shorten >=-3mm] (0,1)--(2,0) node [midway, above] {$A$};
    \end{scope}
   }
   \begin{scope}[draw=blue, densely dashed]
     \draw [] (-1,0)--(0,1)--(1,0)--(0,-1)--cycle;
     \draw [](4.5,0) circle (0.88cm);
     \draw [xshift=9cm] (-.66,-.66) rectangle (.66,.66);
     \begin{scope}[xshift=13.5cm]
       \draw [domain=0:90,samples=100,smooth,variable=\t] plot({-1*cos(\t)^(3)},{1*sin(\t)^(3)});
       \draw [domain=0:90,samples=100,smooth,variable=\t] plot({-1*cos(\t)^(3)},{-1*sin(\t)^(3)});
       \draw [domain=0:90,samples=100,smooth,variable=\t] plot({1*cos(\t)^(3)},{-1*sin(\t)^(3)});
       \draw [domain=0:90,samples=100,smooth,variable=\t] plot({1*cos(\t)^(3)},{1*sin(\t)^(3)});
     \end{scope}
     \foreach \i [count=\j from 0] in {(0,1),(.39,.79),(.66,.66),(0,1)} \scoped [xshift=\j*4.5cm] { \draw [{Circle[width=3pt, length=3pt, fill=black, black]}-{Circle[width=3pt, length=3pt, fill=black, black]}, shorten <=-1.5pt, shorten >=-1.5pt] (0,0) node [below left] {$x$} -- \i node [above right] {$\hat x$} ; };
   \end{scope}
   \foreach \i [count=\j from 0] in {1,2,\infty,\frac{1}{2}} \scoped [xshift=\j*4.5cm] { \node [anchor=mid west] at (0,-1.5) {$p=\i$}; };
\end{tikzpicture}
\end{document}

单一主题的变奏

相关内容