0

I would like to add some information to this graph and I am failing. More specifically,

  • I want the X axis to have the label "nodes" and the Y axis to be seconds
  • I also want the first data set to be called "static" and the second data set to be called "dynamic", perhaps using a red and blue color.

I had to make the graph very vertical to make the "linear" data more visible. I appreciate any help or feedback.

Thank you.

enter image description here

\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}

Node.JS
  • 685
  • Why don't you use pgfplots? I think that it's much easier with it... – Rmano May 22 '23 at 19:44
  • @Rmano please see me previous question https://tex.stackexchange.com/questions/686423/drawing-a-bar-chat-horizontal-or-log-line-chart – Node.JS May 22 '23 at 19:47

1 Answers1

2
\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}

enter image description here