如何在圆柱体上方绘制圆柱体以表示存储数字?

如何在圆柱体上方绘制圆柱体以表示存储数字?

我想要绘制一个Disk/Storage图标,如下所示:

在此处输入图片描述


我想出了:

\documentclass[eblocbroker.tex]{subfiles}
\begin{document}
\begin{figure}[!htp]
    \centering
    \begin{tikzpicture}[%
        >=latex,shorten >=2pt,shorten <=2pt,shape aspect=1,
        arrow/.style={<->, >=stealth, semithick},
        block/.style={},
        every node/.style = {font=\normalsize}
        ]

        \node[
        cylinder,shape border rotate=90,draw,fill=white,
        shape aspect=0.2,font={\baselineskip=9pt},inner xsep=3pt,
        align=center,xshift=30mm,yshift=-2mm] (A) {%
            Cloud Storage \\
            \textit{...} \\
            \textit{...}
        };
        \node[
        cylinder,shape border rotate=90,draw,fill=white,yshift=-2.7mm,
        shape aspect=0.2,font={\baselineskip=9pt},inner xsep=3pt,
        align=center,xshift=30mm,yshift=-2mm] (C) {%
            Cloud Storage
        };

        \node[
        cylinder,shape border rotate=90,draw,fill=white,yshift=2.7mm,
        shape aspect=0.2,font={\baselineskip=9pt},inner xsep=3pt,
        align=center,xshift=30mm,yshift=-2mm] (B) {%
            Cloud Storage
        };


        \node[draw,circle,dashed,inner sep=-1.2pt,draw=gray!50,thick,fit=(A)] (D) {};

    \end{tikzpicture}
\end{figure}
\end{document}

输出:

在此处输入图片描述

我无法在中间绘制子圆柱体。我将文本保留在中间以保持圆柱体的宽度。

答案1

从下往上绘制节点。我建议定义一个style以供重复使用。包含minimum width以保持所有圆柱体大小相同。您可以使用positioning带负片的库node distance来轻松放置。您可以使用\phantom文本来保持空圆柱体具有相同的方面。

在此处输入图片描述

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, positioning, fit}

\tikzset{mycylinder/.style={cylinder, shape border rotate=90, aspect=0.2, draw, fill=white, minimum width=2.5cm}}

\begin{document}
\begin{figure}
    \centering
    \begin{tikzpicture}[node distance=-4mm]
        \node[mycylinder] (C) {Cloud Storage};
        \node[mycylinder, above=of C] (A) {\phantom{Cloud Storage}};
        \node[mycylinder, above=of A] (B) {Cloud Storage};
        \node[draw, circle, dashed, inner sep=-1.2pt, draw=gray!50, thick, fit=(A)(B)(C)] (D) {};
    \end{tikzpicture}
\end{figure}
\end{document}

相关内容