![使用 pgfplots 在 y 轴上绘制图形](https://linux22.com/image/395453/%E4%BD%BF%E7%94%A8%20pgfplots%20%E5%9C%A8%20y%20%E8%BD%B4%E4%B8%8A%E7%BB%98%E5%88%B6%E5%9B%BE%E5%BD%A2.png)
我有一张图表,我想在 Y 轴上绘制图形而不是数字或文本。
我的代码如下:
\begin{tikzpicture}
\begin{axis}
[
xbar, xmin=0, xmax=10,
width=7cm, height=8cm, enlarge y limits=0.5,
xlabel={Closeness to the base firm},
symbolic y coords={
\includegraphics[scale=0.022]{Logo/intellogo.png},
\includegraphics[scale=0.02]{Logo/HPlogo.png},
\includegraphics[scale=0.02]{Logo/nvidialogo.png},
\includegraphics[scale=0.03]{Logo/broadcomlogo.png},
\includegraphics[scale=0.035]{Logo/texasinstrumentslogo.png},
\includegraphics[scale=0.055]{Logo/googlelogo.png},
\includegraphics[scale=0.14]{Logo/microsoftlogo4.png}
},
ytick=data,
nodes near coords, nodes near coords align={horizontal}]
\addplot[xbar,fill={rgb:red,0;green,47;blue,135}] coordinates {
(10, \includegraphics[scale=0.022]{Logo/intellogo.png})
(9, \includegraphics[scale=0.02]{Logo/HPlogo.png})
(8, \includegraphics[scale=0.02]{Logo/nvidialogo.png})
(7, \includegraphics[scale=0.03]{Logo/broadcomlogo.png})
(6, \includegraphics[scale=0.035]{Logo/texasinstrumentslogo.png})
(5, \includegraphics[scale=0.055]{Logo/googlelogo.png})
(4, \includegraphics[scale=0.14]{Logo/microsoftlogo4.png})
};
\end{axis}
\end{tikzpicture}
目前看起来是这样的:
我希望所有徽标按照本\addplot {}
节中提到的 y 值的顺序显示在 Y 轴上
答案1
我设法让它工作了。我删除了放大 y 限制。显然,它使它们相互重叠。
\begin{tikzpicture}
\begin{axis}
[
xbar, xmin=0, xmax=8,
width=7cm, height=10cm,
xlabel={Closeness to the base firm},
symbolic y coords={
\includegraphics[scale=0.022]{Logo/intellogo.png},
\includegraphics[scale=0.02]{Logo/HPlogo.png},
\includegraphics[scale=0.02]{Logo/nvidialogo.png},
\includegraphics[scale=0.03]{Logo/broadcomlogo.png},
\includegraphics[scale=0.035]{Logo/texasinstrumentslogo.png},
\includegraphics[scale=0.055]{Logo/googlelogo.png},
\includegraphics[scale=0.14]{Logo/microsoftlogo4.png}
},
ytick=data,
nodes near coords, nodes near coords align={horizontal}]
\addplot[xbar,fill={rgb:red,0;green,47;blue,135}] coordinates
{
(8,\includegraphics[scale=0.022]{Logo/intellogo.png})
(7,\includegraphics[scale=0.02]{Logo/HPlogo.png})
(6,\includegraphics[scale=0.02]{Logo/nvidialogo.png})
(5,\includegraphics[scale=0.03]{Logo/broadcomlogo.png})
(4,\includegraphics[scale=0.035]{Logo/texasinstrumentslogo.png})
(3,\includegraphics[scale=0.055]{Logo/googlelogo.png})
(2,\includegraphics[scale=0.14]{Logo/microsoftlogo4.png})
};
\end{axis}
\end{tikzpicture}