我想在这个图表中添加一些信息,但我失败了。更具体地说,
- 我希望 X 轴的标签为“节点”,Y 轴为秒
- 我还希望将第一个数据集称为“静态”,将第二个数据集称为“动态”,也许使用红色和蓝色。
我必须将图表做得非常垂直,以使“线性”数据更加清晰可见。非常感谢您的帮助或反馈。
谢谢。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{datavisualization} %for graphs and pictures
\usetikzlibrary{datavisualization.formats.functions} %for graphs and pictures
\begin{document}
\begin{figure}[htbp]
\centering
\begin{tikzpicture}
\datavisualization [scientific axes,
x axis={attribute=nodes, length=10cm},
y axis={attribute=seconds, length=20cm},
visualize as line]
data {
nodes, seconds
3,0.009
30,0.003
111,0.005
354,0.019
1083,0.097
3270,0.044
9831,0.064
29514,0.501
88563,2.276
265710,7.439
797151,27.578
2391474,128.611
}
data {
nodes, seconds
3,0.091
30,0.495
111,2.789
354,3.390
1083,5.021
3270,20.149
9831,48.015
29514,158.442
88563,857.381
265710,2693.862
797151,8771.571
};
\end{tikzpicture}
\end{figure}
\end{document}
答案1
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{datavisualization} %for graphs and pictures
\usetikzlibrary{datavisualization.formats.functions} %for graphs and pictures
\begin{document}
\begin{figure}[htbp]
\centering
\begin{tikzpicture}
\datavisualization [
scientific axes,
x axis={attribute=nodes, length=10cm, label=nodes},
y axis={attribute=seconds, length=20cm, label=seconds},
visualize as line/.list={foo, bar},
foo={style=red,label in legend={text=Foo}},
bar={style=blue,label in legend={text=Bar}},
]
data[set=foo] {
nodes, seconds
3,0.009
30,0.003
111,0.005
354,0.019
1083,0.097
3270,0.044
9831,0.064
29514,0.501
88563,2.276
265710,7.439
797151,27.578
2391474,128.611
}
data[set=bar] {
nodes, seconds
3,0.091
30,0.495
111,2.789
354,3.390
1083,5.021
3270,20.149
9831,48.015
29514,158.442
88563,857.381
265710,2693.862
797151,8771.571
};
\end{tikzpicture}
\end{figure}
\end{document}