Only define \U{} and \E{} workarounds in wtk_graph.asy.
authorW. Trevor King <wking@drexel.edu>
Sun, 2 May 2010 03:59:04 +0000 (23:59 -0400)
committerW. Trevor King <wking@drexel.edu>
Sun, 2 May 2010 04:22:32 +0000 (00:22 -0400)
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
tex/src/figures/cantilever-data/loading-rate.asy
tex/src/figures/cantilever-sim/i-dep.asy
tex/src/figures/cantilever-sim/loading-rate.asy
tex/src/figures/cantilever-sim/v-dep.asy
tex/src/figures/kappa-sawteeth/kappa-sawteeth.asy
tex/src/figures/v-dep/v-dep-sd.asy
tex/src/figures/v-dep/v-dep.asy

index ca7bec1b98dad3b946267fcb920377546778925e..e35a62e56a41a71d3e77e426ae106c59e07f631b 100644 (file)
@@ -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;
index ce6ef9ede3c4bf43dd153e4819e33668f3a4704d..e655b935076f5b47bdeabddcb8f31c666c8f1eb5 100644 (file)
@@ -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);
index caaf1778515cb7cf3a32de6a72796adc74608f80..167743b9786f42dd0ef40259dfd574ad9bb7e5cc 100644 (file)
@@ -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);
index b86ab4c3059f9c5ecb73cfbecb5591a3b25f99e6..c59bbdd6caca471886da824f842e4893e026b3be 100644 (file)
@@ -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);
index 5b34d4e9f3ef116bf55ea6182befba3a872d6a08..8f1efe5cbeb5bd14c9dd3f2969dd755697e3b46e 100644 (file)
@@ -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,
index f5d0b7a88d671d61a3fc14d54d925e32bd20f7ff..e994a17c360d9a689482c35bf464036cbc8e2df3 100644 (file)
@@ -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);
index 5bf72ef6925996ee15c8af15d7e986fb68c4b763..0a9851d4ee3ec34259e1eb94675d9867e926504e 100644 (file)
@@ -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,
index ce4b7b7a8e14c8aee76ecfaea7caefdb018047e3..e5a2a4dd234d1b940fa91fd3bedaa4cd08abc6a5 100644 (file)
@@ -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,