1

I am trying to re-create this pgfplots graph with different data. Instead of "Depth" I have "non-terminal count" or nts for short in the table and I want that a-axis value to be 2^x number format instead of x (its currently x). The "nodes" column is still there.

This is my attempt

enter image description here

\documentclass[12pt,titlepage]{report}

\usepackage[T1]{fontenc} \usepackage{pgfplots}\pgfplotsset{compat=newest} \usetikzlibrary{shapes.symbols}% for starburst \usepackage{pgfplotstable}

\begin{document}

% JastAdd crashed at size 2^13 \pgfplotstableread{ nts Nodes ApsTime ApsMemory JastAddTime JastAddMemory 8 17045 0.6 78 0.8 63 9 67244 2.3 137 2.8 126 10 265762 9.3 479 15 388 11 1024167 72 1288 127 2793 12 3596625 246 5052 983 11073 13 9075268 861 14362 nan nan }\followdata

\begin{figure}[htbp] \centering \begin{tikzpicture}[ slanted blocks/.style={ draw, fill=white, font=\tiny\ttfamily, rotate=45, anchor=south west, inner sep=2pt }] \begin{axis}[ axis line style = {thick, gray}, ymode = log, ymin = .2, xtick = {8,9,...,13}, xlabel = {Non-terminal count}, ylabel = {Time (seconds)}, legend style = {nodes={right, font=\scriptsize}, at={(0.05,0.9)}, anchor=west}, clip mode = individual, grid = major, label style={font=\tiny}, tick label style={font=\tiny} ] \addplot table[x=nts, y=JastAddTime]{\followdata}; \addplot table[x=nts, y=ApsTime]{\followdata}; \legend{JastAdd, APS} \pgfplotsinvokeforeach{8,9,...,12}{ \node[slanted blocks] at ({#1+1},.2) {\pgfplotstablegetelem{#1}{Nodes}\of{\followdata}\pgfplotsretval}; } \node[slanted blocks] at (7.1,.2) {# of nodes}; \node[starburst, fill=yellow, draw=red, thick, font=\tiny\ttfamily, inner sep=0pt, starburst point height=6pt] at (12.5, 2000) {crash!}; \end{axis} \end{tikzpicture}

\end{figure}

\end{document}

Node.JS
  • 685
  • 1
    You should really try to minimize your examples in questions. You are correctly posting compilable examples, but they are far from minimum... my experience is that I often find the problem myself in the "try to reduce this to the minimum" exercise. For example, in this question: reduce it to two-three points, one graph, just the minimum set of packages needed. – Rmano Jun 18 '23 at 09:23
  • @Rmano I updated my attempt – Node.JS Jun 18 '23 at 15:39
  • 1
    It does not compile for me... :-( – Rmano Jun 18 '23 at 15:44

1 Answers1

1

I am not sure if I understood correctly. Are you looking for xticklabel options? You can find it in page 343 of the (current) pgfplots manual.

\documentclass[12pt,titlepage]{report}

\usepackage[T1]{fontenc} \usepackage{pgfplots}\pgfplotsset{compat=newest} \usetikzlibrary{shapes.symbols}% for starburst \usepackage{pgfplotstable}

\begin{document}

% JastAdd crashed at size 2^13 \pgfplotstableread{ nts Nodes ApsTime ApsMemory JastAddTime JastAddMemory 8 17045 0.6 78 0.8 63 9 67244 2.3 137 2.8 126 10 265762 9.3 479 15 388 11 1024167 72 1288 127 2793 12 3596625 246 5052 983 11073 13 9075268 861 14362 nan nan }\followdata

\begin{figure}[htbp] \centering \begin{tikzpicture}[ slanted blocks/.style={ draw, fill=white, font=\tiny\ttfamily, rotate=45, anchor=south west, inner sep=2pt }] \begin{axis}[ axis line style = {thick, gray}, ymode = log, ymin = .2, xtick = {8,9,...,13}, xlabel = {Non-terminal count}, ylabel = {Time (seconds)}, legend style = {nodes={right, font=\scriptsize}, at={(0.05,0.9)}, anchor=west}, clip mode = individual, grid = major, label style={font=\tiny}, tick label style={font=\tiny}, %%% Added: how to create the ticks, manual page 343 "Tick Options" xticklabel={$2^{\pgfmathprintnumber{\tick}}$}, ] \addplot table[x=nts, y=JastAddTime]{\followdata}; \addplot table[x=nts, y=ApsTime]{\followdata}; \legend{JastAdd, APS} \pgfplotsinvokeforeach{0,1,...,5}{%%% changed to compile \node[slanted blocks] at ({#1+8},.2) %% changed to adjust shift {\pgfplotstablegetelem{#1}{Nodes}\of{\followdata}\pgfplotsretval}; } \node[slanted blocks] at (7.1,.2) {# of nodes}; \node[starburst, fill=yellow, draw=red, thick, font=\tiny\ttfamily, inner sep=0pt, starburst point height=6pt] at (12.5, 2000) {crash!}; \end{axis} \end{tikzpicture} \end{figure} \end{document}

enter image description here

Rmano
  • 40,848
  • 3
  • 64
  • 125