![如何在 Latex 中绘制打孔卡](https://linux22.com/image/295576/%E5%A6%82%E4%BD%95%E5%9C%A8%20Latex%20%E4%B8%AD%E7%BB%98%E5%88%B6%E6%89%93%E5%AD%94%E5%8D%A1%20.png)
我想在 Latex 中绘制如下所示的打孔卡。但我找不到任何有关如何执行此操作的信息(甚至在 tikz 手册中也没有)。我唯一能找到的是有关气泡图(带有 x 和 y 轴)的信息。我想从 csv 文件中获取数据,例如使用以下命令:
\addplot table {table.csv}
将我的数据链接为 .ods 文件:https://www.dropbox.com/s/3qgdh9klo2xpxcz/punchcard.ods
作为 csv 文件(无标题):https://www.dropbox.com/s/10ql1wzf8ired9p/punchcard-csv.csv
该图片的来源是 Maalej 和 Robillard 的文章:API 参考文档中的知识模式
答案1
\documentclass{standalone}
\usepackage{mathpazo}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\definecolor{skyblue}{rgb}{0.447,0.624,0.812}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
grid=major,
point meta=explicit,
scatter/@pre marker code/.code={
\pgfmathparse{
\pgfplotspointmetatransformed/1000*50+50}
\let\opacity=\pgfmathresult
\pgfmathparse{
\pgfplotspointmetatransformed/1000*6.5+1}
\def\markopts{
mark=*,
color=skyblue!\opacity,
fill=skyblue!\opacity,
mark size=\pgfmathresult}
\expandafter\scope\expandafter[\markopts]},
scatter/@post marker code/.code={
\endscope},
symbolic x coords={Type2,Type3,Type4,Type5,Type6,Type7,Type8,Type9,Type10,Type11,Type12},
symbolic y coords={Type12,Type11,Type10,Type9,Type8,Type7,Type6,Type5,Type4,Type3,Type2,Type1}]
\addplot[only marks,scatter]
table[x index=0, y index=1, meta index=2] {punchcard.csv};
\end{axis}
\end{tikzpicture}
\end{document}