tikz 气泡图

tikz 气泡图

我想要生成如下所示的气泡图。

在此处输入图片描述

然而我真正想要的是像下面的情节。

在此处输入图片描述

以下是我尝试过的。

\begin{tikzpicture}
      \begin{axis}[
          width=4.5in,
          height=3.5in,
          xtick=data,
          symbolic x coords = {A,B,C,D},
          scale only axis,
          xticklabel style={rotate=45,anchor=east,align=center},
          xticklabels={Social media,Remote sensing,CCTV,WSN and IoT},
       ]
      \addplot[%
          scatter=true,
          only marks,
          mark=*,
          point meta=explicit,
          visualization depends on = {0.5*\thisrow{Val} \as \perpointmarksize},
          scatter/@pre marker code/.append style={/tikz/mark size=\perpointmarksize},
      ] table [x={x},y={Yval},meta index=2] {
x  Algorithm Val Yval
A  CNN  2 2
A  RNN  8 4
B  RNN  15 4
C  RNN  10 4
D  CNN  4 2
};      
\end{axis}
\end{tikzpicture}

答案1

你已经非常接近了,但这可能需要另一次迭代,因为我显然不知道哪一列要放到哪里。

\documentclass[tikz,border=3mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17}
\begin{document}
\begin{tikzpicture}
      \begin{axis}[
          width=4.5in,
          height=3.5in,
          xtick=data,
          symbolic x coords = {A,B,C,D},
          symbolic y coords = {CNN,RNN,AE,AE},
          ytick distance=1,ymax=AE,
          scale only axis,
          xticklabel style={rotate=45,anchor=east,align=center},
          xticklabels={Social media,Remote sensing,CCTV,WSN and IoT},
       ]
      \addplot[%
          scatter=true,
          only marks,
          mark=*,
          point meta=explicit,
          fill opacity=0.5,text opacity=1,
          visualization depends on = {2*\thisrow{Val} \as \perpointmarksize},
          scatter/@pre marker code/.append style={
          /tikz/mark size=\perpointmarksize,/tikz/mark options={draw=none}},
          nodes near coords*,
          nodes near coords style={text=white,font=\sffamily,anchor=center},
      ] table [x={x},y={Algorithm},meta index=2] {
x  Algorithm Val Yval
A  CNN  2 2
A  RNN  8 4
B  RNN  15 4
C  RNN  10 4
D  CNN  4 2
};      
\end{axis}
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容