我如何将这些条形图放置在其左侧和右侧而不是一个在另一个下面列出?

我如何将这些条形图放置在其左侧和右侧而不是一个在另一个下面列出?
\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\node [anchor=west] at (.1,.8) {Java};
\draw [fill=gray] (0,0) rectangle (5,.5);
\draw [fill={rgb:red,1;green,2;blue,3}] (0,0) rectangle (.1,.5);
\end{tikzpicture}

\vspace{.05cm}
\begin{tikzpicture}
\node [anchor=west] at (.1,.8) {polite};
\draw [fill=gray] (0,0) rectangle (5,.5);
\draw [fill={rgb:red,1;green,2;blue,3}] (0,0) rectangle (3.5,.5);
\end{tikzpicture}

\vspace{.05cm}
\begin{tikzpicture}
\node [anchor=west] at (.1,.8) {outgoing};
\draw [fill=gray] (0,0) rectangle (5,.5);
\draw [fill={rgb:red,1;green,2;blue,3}] (0,0) rectangle (4,.5);
\end{tikzpicture}

\vspace{.05cm}
\begin{tikzpicture}
\node [anchor=west] at (.1,.8) {good manners};
\draw [fill=gray] (0,0) rectangle (5,.5);
\draw [fill={rgb:red,1;green,2;blue,3}] (0,0) rectangle (3.5,.5);
\end{tikzpicture}

\vspace{.05cm}
\begin{tikzpicture}
\node [anchor=west] at (.1,.8) {pursuer of rabbits};
\draw [fill=gray] (0,0) rectangle (5,.5);
\draw [fill={rgb:red,1;green,2;blue,3}] (0,0) rectangle (4.8,.5);
\end{tikzpicture}
\end{document}

答案1

将它们全部放在一个位置tikzpicture,然后使用scope它们将它们移动到您喜欢的任何位置。使用tikzpicture(或scope)上的刻度可以更改尺寸。为了清楚起见,我还将第一个放在一个示波器中并打印了所有移位,甚至 0cm。

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
  \begin{scope}[xshift=0cm,yshift=0cm]
    \node [anchor=west] at (.1,.8) {Java};
    \draw [fill=gray] (0,0) rectangle (5,.5);
    \draw [fill={rgb:red,1;green,2;blue,3}] (0,0) rectangle (.1,.5);
  \end{scope}
  \begin{scope}[xshift=6cm,yshift=0cm]
    \node [anchor=west] at (.1,.8) {polite};
    \draw [fill=gray] (0,0) rectangle (5,.5);
    \draw [fill={rgb:red,1;green,2;blue,3}] (0,0) rectangle (3.5,.5);
  \end{scope}
  \begin{scope}[xshift=0cm,yshift=-2cm]
    \node [anchor=west] at (.1,.8) {outgoing};
    \draw [fill=gray] (0,0) rectangle (5,.5);
    \draw [fill={rgb:red,1;green,2;blue,3}] (0,0) rectangle (4,.5);
  \end{scope}
  \begin{scope}[xshift=6cm,yshift=-2cm]
    \node [anchor=west] at (.1,.8) {good manners};
    \draw [fill=gray] (0,0) rectangle (5,.5);
    \draw [fill={rgb:red,1;green,2;blue,3}] (0,0) rectangle (3.5,.5);
  \end{scope}
  \begin{scope}[xshift=0cm,yshift=-4cm]
    \node [anchor=west] at (.1,.8) {pursuer of rabbits};
    \draw [fill=gray] (0,0) rectangle (5,.5);
    \draw [fill={rgb:red,1;green,2;blue,3}] (0,0) rectangle (4.8,.5);
  \end{scope}
\end{tikzpicture}
\end{document}

enter image description here

答案2

缩放比例为.6和不缩放比例时,\vspace您至少会得到三个并排的图像。实验是关键(以便正确地将所有图像放到一行中)。

picture of tikzpictures

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}[scale=.6]
\node [anchor=west] at (.1,.8) {Java};
\draw [fill=gray] (0,0) rectangle (5,.5);
\draw [fill={rgb:red,1;green,2;blue,3}] (0,0) rectangle (.1,.5);
\end{tikzpicture}\hfill
\begin{tikzpicture}[scale=.6]
\node [anchor=west] at (.1,.8) {polite};
\draw [fill=gray] (0,0) rectangle (5,.5);
\draw [fill={rgb:red,1;green,2;blue,3}] (0,0) rectangle (3.5,.5);
\end{tikzpicture}\hfill
\begin{tikzpicture}[scale=.6]
\node [anchor=west] at (.1,.8) {outgoing};
\draw [fill=gray] (0,0) rectangle (5,.5);
\draw [fill={rgb:red,1;green,2;blue,3}] (0,0) rectangle (4,.5);
\end{tikzpicture}\hfill
\begin{tikzpicture}[scale=.6]
\node [anchor=west] at (.1,.8) {good manners};
\draw [fill=gray] (0,0) rectangle (5,.5);
\draw [fill={rgb:red,1;green,2;blue,3}] (0,0) rectangle (3.5,.5);
\end{tikzpicture}\hfill
\begin{tikzpicture}[scale=.6]
\node [anchor=west] at (.1,.8) {pursuer of rabbits};
\draw [fill=gray] (0,0) rectangle (5,.5);
\draw [fill={rgb:red,1;green,2;blue,3}] (0,0) rectangle (4.8,.5);
\end{tikzpicture}
\end{document}

相关内容