# Improve the 2d graph as family of curves in 3d

I have the (x,y) coordinates for a set/family of curves. Each each curve corresponds to a different z value, but there is no correlation of x or y values from curve to curve. I.e., I can't express the set of curves as a table, it is really several lists of x,y pairs.

I'd like to experiment with making the curves 3d, to see if that makes it easier to read, and if I can thereafter eliminate the need for color encoding. I would like to avoid color encoding to be kinder to a color blind audience, and also to make it possible to print in black&white.

The latex code is given below. Can someone suggest a way transform this into a 3d image? Do I need to start over and use a completely different package, or can I do this with some tweaks still using the tikzpicture and friends?

Suggestions welcomed.

\documentclass{article}
\usepackage{pgfplots}

\begin{document}
\begin{figure}
\begin{tikzpicture}
\begin{axis}[
xlabel=BDD Size,
ymajorgrids,
yminorgrids,
xmajorgrids,
xminorgrids,
ylabel=Probability,
legend style={font=\tiny},
label style={font=\tiny}
]
(1,0.125)
(3,0.25)
(4,0.5)
(5,0.125)
};
(1,0.0078125)
(3,0.0234375)
(4,0.09375)
(5,0.2421875)
(6,0.34375)
(7,0.2890625)
};
(1,0.001998002)
(3,9.99001e-4)
(5,0.003996004)
(6,0.00999001)
(7,0.062937066)
(8,0.14985014)
(9,0.25174826)
(10,0.36963037)
(11,0.14885116)
};
(1,0.001998002)
(7,9.99001e-4)
(9,9.99001e-4)
(11,0.003996004)
(12,0.018981019)
(13,0.05894106)
(14,0.14085914)
(15,0.22077923)
(16,0.3126873)
(17,0.17782217)
(18,0.05894106)
(19,0.002997003)
};
(1,0.001998002)
(8,9.99001e-4)
(18,9.99001e-4)
(20,9.99001e-4)
(21,0.003996004)
(22,0.017982017)
(23,0.04995005)
(24,0.0989011)
(25,0.17682318)
(26,0.22977023)
(27,0.21278721)
(28,0.15484515)
(29,0.03996004)
(30,0.008991009)
(31,9.99001e-4)
};
(1,0.001998002)
(9,9.99001e-4)
(38,0.003996004)
(39,0.006993007)
(40,0.022977022)
(41,0.050949052)
(42,0.1058941)
(43,0.17582418)
(44,0.21578422)
(45,0.21778221)
(46,0.15084915)
(47,0.045954045)
};
(1,0.001998002)
(10,9.99001e-4)
(67,9.99001e-4)
(69,9.99001e-4)
(70,0.014985015)
(71,0.021978023)
(72,0.064935066)
(73,0.10489511)
(74,0.16483517)
(75,0.21378621)
(76,0.2007992)
(77,0.13286713)
(78,0.064935066)
(79,0.010989011)
};
\legend{"Size with 2 variables","Size with 3 variables","Size with 4 variables","Size with 5 variables","Size with 6 variables","Size with 7 variables","Size with 8 variables"}
\end{axis}
\end{tikzpicture}

\end{figure}
\end{document}


I'd take a different tack. I'd stick with 2D for the printed page, but I'd use the power of a programmable drawing tool to draw the chart "by hand" instead of trying to get the graphing package to do all you need here automatically.

Here I've used Metapost wrapped up in luamplib (so you need to compile with with lualatex or adapt it for Plain MP or the gmp package). Others can show you how to do similar things with TikZ.

I've written a custom addplot routine to do each of the curves. And I've used the programmable power of the language to change the dash patterns for each line, and add the labels where they are needed instead of having that clunky legend.

\RequirePackage{luatex85}
\documentclass[border=5mm]{standalone}
\usepackage{luamplib}
\begin{document}
\mplibtextextlabel{enable}
\begin{mplibcode}
beginfig(1);

path p_; pair maximum; maximum := first;
p_ := (first for $=list_of_pairs: --$
hide(if ypart $> ypart maximum: maximum :=$; fi)
endfor) xscaled u yscaled v;
draw p_ dashed evenly scaled (2/n);
for t=0 upto length p_: fill fullcircle scaled 2 shifted point t of p_; endfor
if n=3:
draw hide(maximum := maximum shifted (0.1,0.01)) maximum xscaled u yscaled v --
hide(maximum := maximum shifted (  1,0.08)) maximum xscaled u yscaled v
withpen pencircle scaled 1/4;
fi
label.urt("$n=" & decimal n & "$", maximum xscaled u yscaled v);
enddef;

beginfig(1);

numeric n, u, v;
u = 120mm/80; v = 80mm;

path xx, yy;
xx = (origin -- right) scaled 85u shifted 10 down;
yy = (origin -- up) scaled .6 v shifted 10 left;

drawoptions(withcolor 1/4 white);
drawarrow xx;  label("BDD Size", point 1/2 of xx shifted 20 down);
drawarrow yy;  label("Probability", point 1 of yy shifted 10 up);
for i=0 step 20 until 80: label.bot(decimal i, (i*u,-10)); endfor
for i=0 step 1 until 5: label.lft(decimal (i/10), (-10,i*v/10)); endfor
drawoptions();

label("BDD size with $n$ variables", (60u, 0.5v));

n := 2;
(1,0.125),
(3,0.25),
(4,0.5),
(5,0.125));
n := 3;
(1,0.0078125),
(3,0.0234375),
(4,0.09375),
(5,0.2421875),
(6,0.34375),
(7,0.2890625));
n := 4;
(1,0.001998002),
(3,0.000999001),
(5,0.003996004),
(6,0.00999001),
(7,0.062937066),
(8,0.14985014),
(9,0.25174826),
(10,0.36963037),
(11,0.14885116));
n := 5;
(1,0.001998002),
(7,0.000999001),
(9,0.000999001),
(11,0.003996004),
(12,0.018981019),
(13,0.05894106),
(14,0.14085914),
(15,0.22077923),
(16,0.3126873),
(17,0.17782217),
(18,0.05894106),
(19,0.002997003));
n := 6;
(1,0.001998002),
(8,0.000999001),
(18,0.000999001),
(20,0.000999001),
(21,0.003996004),
(22,0.017982017),
(23,0.04995005),
(24,0.0989011),
(25,0.17682318),
(26,0.22977023),
(27,0.21278721),
(28,0.15484515),
(29,0.03996004),
(30,0.008991009),
(31,0.000999001));
n := 7;
(1,0.001998002),
(9,0.000999001),
(38,0.003996004),
(39,0.006993007),
(40,0.022977022),
(41,0.050949052),
(42,0.1058941),
(43,0.17582418),
(44,0.21578422),
(45,0.21778221),
(46,0.15084915),
(47,0.045954045));
n := 8;
(1,0.001998002),
(10,0.000999001),
(67,0.000999001),
(69,0.000999001),
(70,0.014985015),
(71,0.021978023),
(72,0.064935066),
(73,0.10489511),
(74,0.16483517),
(75,0.21378621),
(76,0.2007992),
(77,0.13286713),
(78,0.064935066),
(79,0.010989011));

endfig;
\end{mplibcode}
\end{document}

• Thanks Thruston, but that sounds like a heavy hammer. It is an article I'm submitting to an ACM journal. I'm weary of which packages I use, as I don't know which packages ACM journals allow. Are you sure your proposed solution is acceptable for a journal submission? – Jim Newton Dec 15 '17 at 13:57
• No idea. But if in doubt you could just compile the chart to a stand-alone PDF and put iron with includegraphic. – Thruston Dec 15 '17 at 15:09
• Thanks Thruston for your suggestion. I still wonder whether anyone else has another suggestion? – Jim Newton Dec 18 '17 at 16:28