From 7a0437604d096a24ff83e8f7a3b16e5958e5337b Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sat, 1 May 2010 23:59:04 -0400 Subject: [PATCH] Only define \U{} and \E{} workarounds in wtk_graph.asy. We need redefinitions beacause asymptote missaligns labels if we use \U{} and \E{} directly. However, lots of \mbox{} and \cdot10^{} cruft is both ugly and brittle. The reworked units() and new Exp() should be used instead. math(string) is a simple replacement for "$"+string+"$" which looks clearer to me in most cases, so I've added that too. --- tex/src/figures/asy/wtk_graph.asy | 10 ++++++- .../figures/cantilever-data/loading-rate.asy | 4 +-- tex/src/figures/cantilever-sim/i-dep.asy | 30 +++++++++++-------- .../figures/cantilever-sim/loading-rate.asy | 4 +-- tex/src/figures/cantilever-sim/v-dep.asy | 12 ++++---- .../figures/kappa-sawteeth/kappa-sawteeth.asy | 4 +-- tex/src/figures/v-dep/v-dep-sd.asy | 14 +++++---- tex/src/figures/v-dep/v-dep.asy | 15 ++++++---- 8 files changed, 56 insertions(+), 37 deletions(-) diff --git a/tex/src/figures/asy/wtk_graph.asy b/tex/src/figures/asy/wtk_graph.asy index ca7bec1..e35a62e 100644 --- a/tex/src/figures/asy/wtk_graph.asy +++ b/tex/src/figures/asy/wtk_graph.asy @@ -187,8 +187,16 @@ void graphMatrixFile(picture pic=currentpicture, string file="datafile", final=p_final_graph, axis=Right, palette=p); } +string math(string contents) { + return "$" + contents + "$"; +} + +string Exp(string value) { + return "\cdot 10^{" + value + "}"; +} + string units(string value, string units) { - return "$"+value+"\mbox{ "+units+"}$"; + return value+"\mbox{ "+units+"}"; } pen phard=blue; diff --git a/tex/src/figures/cantilever-data/loading-rate.asy b/tex/src/figures/cantilever-data/loading-rate.asy index ce6ef9e..e655b93 100644 --- a/tex/src/figures/cantilever-data/loading-rate.asy +++ b/tex/src/figures/cantilever-data/loading-rate.asy @@ -7,9 +7,9 @@ real xscale=1; real yscale=1; graphFile("loading-rate.d/loading_rate_131.98.dat", xscale, yscale, phard, m8, - t=units("131.98","pN/nm"), dots=true); + t=math(units("131.98","pN/nm")), dots=true); graphFile("loading-rate.d/loading_rate_24.33.dat", xscale, yscale, red, m8, - t=units("24.33","pN/nm"), dots=true); + t=math(units("24.33","pN/nm")), dots=true); xlimits(1,3e3); ylimits(90,620); diff --git a/tex/src/figures/cantilever-sim/i-dep.asy b/tex/src/figures/cantilever-sim/i-dep.asy index caaf177..167743b 100644 --- a/tex/src/figures/cantilever-sim/i-dep.asy +++ b/tex/src/figures/cantilever-sim/i-dep.asy @@ -5,18 +5,24 @@ scale(Linear, Linear); real xscale=1; real yscale=1e12; -graphFile("i-dep.d/i_dep_127_8_1e-6", xscale, yscale, phard, m8, t=units("127","pN/nm")+", 8 domains"); -graphFile("i-dep.d/i_dep_27_8_1e-6", xscale, yscale, pmed, m8, t=units("27","pN/nm")+", 8 domains"); -graphFile("i-dep.d/i_dep_127_30_1e-6", xscale, yscale, phard, m30, t=units("127","pN/nm")+", 30 domains"); -graphFile("i-dep.d/i_dep_27_30_1e-6", xscale, yscale, pmed, m30, t=units("27","pN/nm")+", 30 domains"); -graphFile("i-dep.d/i_dep_0.1_1_1e-6", xscale, yscale, psoft, m1, t=units("0.1","pN/nm")+", 1 domain"); -graphFile("i-dep.d/i_dep_0.1_30_1e-6", xscale, yscale, psoft, m30, t=units("0.1","pN/nm")+", 30 domains"); +graphFile("i-dep.d/i_dep_127_8_1e-6", xscale, yscale, phard, m8, + t=math(units("127","pN/nm"))+", 8 domains"); +graphFile("i-dep.d/i_dep_27_8_1e-6", xscale, yscale, pmed, m8, + t=math(units("27","pN/nm"))+", 8 domains"); +graphFile("i-dep.d/i_dep_127_30_1e-6", xscale, yscale, phard, m30, + t=math(units("127","pN/nm"))+", 30 domains"); +graphFile("i-dep.d/i_dep_27_30_1e-6", xscale, yscale, pmed, m30, + t=math(units("27","pN/nm"))+", 30 domains"); +graphFile("i-dep.d/i_dep_0.1_1_1e-6", xscale, yscale, psoft, m1, + t=math(units("0.1","pN/nm"))+", 1 domain"); +graphFile("i-dep.d/i_dep_0.1_30_1e-6", xscale, yscale, psoft, m30, + t=math(units("0.1","pN/nm"))+", 30 domains"); -//xlimits(1,10); -ylimits(140,320); +ylimits(140, 320); -label(sLabel("Peak index dependence ("+units("1.0","$\mu$m/s")+")"), point(N),N); -xaxis(sLabel("Peak index"),BottomTop,LeftTicks); -yaxis(sLabel("Unfolding force (pN)"),LeftRight,RightTicks); +label(sLabel("Peak index dependence ($"+units("1.0","$\mu$m/s")+"$)"), + point(N), N); +xaxis(sLabel("Peak index"), BottomTop, LeftTicks); +yaxis(sLabel("Unfolding force (pN)"), LeftRight, RightTicks); -add(legend(),point(E),20E,UnFill); +add(legend(), point(E), 20E, UnFill); diff --git a/tex/src/figures/cantilever-sim/loading-rate.asy b/tex/src/figures/cantilever-sim/loading-rate.asy index b86ab4c..c59bbdd 100644 --- a/tex/src/figures/cantilever-sim/loading-rate.asy +++ b/tex/src/figures/cantilever-sim/loading-rate.asy @@ -8,10 +8,10 @@ real yscale=1e12; graphFile(file="loading-rate.d/loading_rate_dep_127_8", xscale=xscale, yscale=yscale, p=phard, mpath=mdot, - t=units("127","pN/nm"), dots=true); + t=math(units("127","pN/nm")), dots=true); graphFile(file="loading-rate.d/loading_rate_dep_27_8", xscale=xscale, yscale=yscale, p=red, mpath=mdot, - t=units("27","pN/nm"), dots=true); + t=math(units("27","pN/nm")), dots=true); xlimits(20,7e5); ylimits(40,400); diff --git a/tex/src/figures/cantilever-sim/v-dep.asy b/tex/src/figures/cantilever-sim/v-dep.asy index 5b34d4e..8f1efe5 100644 --- a/tex/src/figures/cantilever-sim/v-dep.asy +++ b/tex/src/figures/cantilever-sim/v-dep.asy @@ -15,17 +15,17 @@ real fn_logxliny(real x, real[] params) { } graphFile("v-dep.d/v_dep_127_8", vscale, fscale, p=phard, mpath=m8, - t=units("127","pN/nm")+", 8 domains", dots=true); + t=math(units("127","pN/nm"))+", 8 domains", dots=true); graphFile("v-dep.d/v_dep_27_8", vscale, fscale, p=pmed, mpath=m8, - t=units("27","pN/nm")+", 8 domains", dots=true); + t=math(units("27","pN/nm"))+", 8 domains", dots=true); graphFile("v-dep.d/v_dep_127_30", vscale, fscale, p=phard, mpath=m30, - t=units("127","pN/nm")+", 30 domains", dots=true); + t=math(units("127","pN/nm"))+", 30 domains", dots=true); graphFile("v-dep.d/v_dep_27_30", vscale, fscale, p=pmed, mpath=m30, - t=units("27","pN/nm")+", 30 domains", dots=true); + t=math(units("27","pN/nm"))+", 30 domains", dots=true); graphFile("v-dep.d/v_dep_0.1_1", vscale, fscale, p=psoft, mpath=m1, - t=units("0.1","pN/nm")+", 1 domain", dots=true); + t=math(units("0.1","pN/nm"))+", 1 domain", dots=true); graphFile("v-dep.d/v_dep_0.1_30", vscale, fscale, p=psoft, mpath=m30, - t=units("0.1","pN/nm")+", 30 domains", dots=true); + t=math(units("0.1","pN/nm"))+", 30 domains", dots=true); fitFile("v-dep.d/v_dep_127_8.fit.dat", f=fn_logxliny, xmin=1e-9, xmax=1e-5, xscale=vscale, yscale=fscale, p=phard); fitFile("v-dep.d/v_dep_27_8.fit.dat", f=fn_logxliny, diff --git a/tex/src/figures/kappa-sawteeth/kappa-sawteeth.asy b/tex/src/figures/kappa-sawteeth/kappa-sawteeth.asy index f5d0b7a..e994a17 100644 --- a/tex/src/figures/kappa-sawteeth/kappa-sawteeth.asy +++ b/tex/src/figures/kappa-sawteeth/kappa-sawteeth.asy @@ -26,9 +26,9 @@ for (i=k.length-1; i>=0; --i) {/* count down so legend and plot orders match */ string file = format("k-%f", k[i])+"."+"dat"; /* We break up .dat so the Asymptote scanner doesn't pick up * .dat as a dependency (which obviously doesn't exist). */ - string label = format("$k=%f\mbox{ pN/nm}$", k[i]*1e3); + string label = math("k="+units(format("%f",k[i]*1e3), "pN/nm")); if (k[i] >= 1) - label = format("$k=%f\mbox{ nN/nm}$", k[i]); + label = math("k="+units(format("%f",k[i]),"nN/nm")); // TODO: rainbow pen(N, i) graphSawtooth(file=file, k=k[i], xscale=xscale, fscale=fscale, df=300e-12*i, p=psoft, t=label); diff --git a/tex/src/figures/v-dep/v-dep-sd.asy b/tex/src/figures/v-dep/v-dep-sd.asy index 5bf72ef..0a9851d 100644 --- a/tex/src/figures/v-dep/v-dep-sd.asy +++ b/tex/src/figures/v-dep/v-dep-sd.asy @@ -15,18 +15,20 @@ real fn_logxliny(real x, real[] params) { return params[0] * log10(x) + params[1]; } +string kx_title(string kval, string kexp, string xval) { + return math("k_{u0}=" + units("5"+Exp("-5"),"s$^{-1}$")) + +", " + math("\Delta x_u=" + units(xval,"nm")); +} + graphFile(pic, "v_dep-5e-5_0.1e-9/v_dep", ycol=2, xscale=xscale, yscale=yscale, p=psoft, - t="$k_{u0}=5\cdot10^{-5}\mbox{ s$^{-1}$}$, $\Delta x_u=0.100\mbox{ nm}$", - dots=true); + t=kx_title(kval="5", kexp="-5", xval="0.100"), dots=true); graphFile(pic, "v_dep-1e-5_0.225e-9/v_dep", ycol=2, xscale=xscale, yscale=yscale, p=pmed, - t="$k_{u0}=1\cdot10^{-5}\mbox{ s$^{-1}$}$, $\Delta x_u=0.225\mbox{ nm}$", - dots=true); + t=kx_title(kval="1", kexp="-5", xval="0.225"), dots=true); graphFile(pic, "v_dep-5e-5_0.225e-9/v_dep", ycol=2, xscale=xscale, yscale=yscale, p=phard, - t="$k_{u0}=5\cdot10^{-5}\mbox{ s$^{-1}$}$, $\Delta x_u=0.225\mbox{ nm}$", - dots=true); + t=kx_title(kval="5", kexp="-5", xval="0.225"), dots=true); fitFile(pic, "v_dep-5e-5_0.1e-9/v_dep-sd.fit.dat", f=fn_logxliny, xmin=1e-9, xmax=1e-5, xscale=xscale, yscale=yscale, p=psoft); fitFile(pic, "v_dep-1e-5_0.225e-9/v_dep-sd.fit.dat", f=fn_logxliny, diff --git a/tex/src/figures/v-dep/v-dep.asy b/tex/src/figures/v-dep/v-dep.asy index ce4b7b7..e5a2a4d 100644 --- a/tex/src/figures/v-dep/v-dep.asy +++ b/tex/src/figures/v-dep/v-dep.asy @@ -11,15 +11,18 @@ real fn_logxliny(real x, real[] params) { return params[0] * log10(x) + params[1]; } +string kx_title(string kval, string kexp, string xval) { + return math("k_{u0}=" + units("5"+Exp("-5"),"s$^{-1}$")) + +", " + math("\Delta x_u=" + units(xval,"nm")); +} + + graphFile("v_dep-5e-5_0.1e-9/v_dep", xscale=xscale, yscale=yscale, p=psoft, - t="$k_{u0}=5\cdot10^{-5}\mbox{ s$^{-1}$}$, $\Delta x_u=0.100\mbox{ nm}$", - dots=true); + t=kx_title(kval="5", kexp="-5", xval="0.100"), dots=true); graphFile("v_dep-1e-5_0.225e-9/v_dep", xscale=xscale, yscale=yscale, p=pmed, - t="$k_{u0}=1\cdot10^{-5}\mbox{ s$^{-1}$}$, $\Delta x_u=0.225\mbox{ nm}$", - dots=true); + t=kx_title(kval="1", kexp="-5", xval="0.225"), dots=true); graphFile("v_dep-5e-5_0.225e-9/v_dep", xscale=xscale, yscale=yscale, p=phard, - t="$k_{u0}=5\cdot10^{-5}\mbox{ s$^{-1}$}$, $\Delta x_u=0.225\mbox{ nm}$", - dots=true); + t=kx_title(kval="5", kexp="-5", xval="0.225"), dots=true); fitFile("v_dep-5e-5_0.1e-9/v_dep.fit.dat", f=fn_logxliny, xmin=1e-9, xmax=1e-5, xscale=xscale, yscale=yscale, p=psoft); fitFile("v_dep-1e-5_0.225e-9/v_dep.fit.dat", f=fn_logxliny, -- 2.26.2