From: W. Trevor King Date: Sat, 1 May 2010 02:36:20 +0000 (-0400) Subject: Converted sim-sawtooth from Gnuplot to Asymptote. X-Git-Tag: v1.0~383 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=bf3cbfefeb07c9d86dcb9d983d84ee2e9a0b21be;p=thesis.git Converted sim-sawtooth from Gnuplot to Asymptote. --- diff --git a/tex/src/figures/asy/wtk_graph.asy b/tex/src/figures/asy/wtk_graph.asy index 778252b..072d292 100644 --- a/tex/src/figures/asy/wtk_graph.asy +++ b/tex/src/figures/asy/wtk_graph.asy @@ -14,31 +14,42 @@ Label sLabel(string s, align align=NoAlign, int extra_spaces=0) { return Label(s+spaces, s+spaces, fontsize(fsize), align=align); } -void graphFile(picture pic=currentpicture, string file="datafile", - int xcol=0, int ycol=1, - real xscale=1, real yscale=1, pen p=red, +void graphData(picture pic=currentpicture, real[] x, real[] y, + real xscale=1, real yscale=1, real dx=0, real dy=0, pen p=red, path mpath=scale(0.8mm)*unitcircle, markroutine markroutine=marknodes, string t="Title", bool dots=false) { pen pline=p; marker mk = nomarker; - file fin=input(file).line(); - real[][] a=fin.dimension(0,0); - a=transpose(a); - real[] x=a[xcol]; - real[] y=a[ycol]; if (dots == true) { pline = invisible; mk = marker(mpath, markroutine, p); } if (t != "Title") { - draw(pic=pic, graph(pic,xscale*x,yscale*y), p=pline, legend=sLabel(t,extra_spaces=1), marker=mk); + draw(pic=pic, graph(pic,xscale*(x+dx),yscale*(y+dy)), p=pline, + legend=sLabel(t,extra_spaces=1), marker=mk); } else { - draw(pic=pic, graph(pic,xscale*x,yscale*y), p=pline, marker=mk); + draw(pic=pic, graph(pic,xscale*(x+dx),yscale*(y+dy)), p=pline, marker=mk); } } +void graphFile(picture pic=currentpicture, string file="datafile", + int xcol=0, int ycol=1, + real xscale=1, real yscale=1, real dx=0, real dy=0, pen p=red, + path mpath=scale(0.8mm)*unitcircle, + markroutine markroutine=marknodes, + string t="Title", + bool dots=false) { + file fin=input(file).line(); + real[][] a=fin.dimension(0,0); + a=transpose(a); + real[] x=a[xcol]; + real[] y=a[ycol]; + graphData(pic=pic, x=x, y=y, xscale=xscale, yscale=yscale, dx=dx, dy=dy, p=p, + mpath=mpath, markroutine=markroutine, t=t, dots=dots); +} + void fitFile(picture pic=currentpicture, string file="fitparamfile", int pcol=0, real f(real x, real[] params), real xmin=realMin, real xmax=realMax, diff --git a/tex/src/figures/sim-sawtooth/SConscript b/tex/src/figures/sim-sawtooth/SConscript index 8ecd2a1..1bff1dc 100644 --- a/tex/src/figures/sim-sawtooth/SConscript +++ b/tex/src/figures/sim-sawtooth/SConscript @@ -1,9 +1,16 @@ +from site_cons.site_init import link_wtk_graph + + +FIGURES = ['sim-sawtooth'] + # Get the passed in environment. Import('env') -for gp in Glob('*.gp'): - env.Gnuplot(gp) +wtk_graph = link_wtk_graph(env) + +for fig in FIGURES: + asyfile = '%s.asy' % fig # static .asy file + env.Asymptote([asyfile, wtk_graph]) # Pass back the modified environment. Return('env') - diff --git a/tex/src/figures/sim-sawtooth/fig.gp b/tex/src/figures/sim-sawtooth/fig.gp deleted file mode 100644 index 3b5a921..0000000 --- a/tex/src/figures/sim-sawtooth/fig.gp +++ /dev/null @@ -1,35 +0,0 @@ -set terminal pdf font 'Times,7' size 9cm, 6cm -set output 'fig.pdf' -unset key -set style data lines -set xrange [-5:250] -set yrange [-10:400] -set ytics 0,100 -set xtics nomirror -set ytics nomirror -# border 3 = bottom & left -set border 3 -set lmargin 9 - -set multiplot - -set size 1,0.42; -set origin 0.0,0.0; -set xlabel 'Extension (nm)' -plot 'fig1.d' using (($1-$2/0.05)*1e9):($2*1e12) - -set size 1,0.29; -set origin 0.0,0.42; -set bmargin 0 -unset xlabel -set xtics format "" -set ylabel 'Force (pN)' -plot 'fig2.d' using (($1-$2/0.05)*1e9):($2*1e12) - -set origin 0.0,0.71; -set bmargin 0 -set xtics format "" -unset ylabel -plot 'fig3.d' using (($1-$2/0.05)*1e9):($2*1e12) - -unset multiplot diff --git a/tex/src/figures/sim-sawtooth/fig1.d b/tex/src/figures/sim-sawtooth/fig1.dat similarity index 100% rename from tex/src/figures/sim-sawtooth/fig1.d rename to tex/src/figures/sim-sawtooth/fig1.dat diff --git a/tex/src/figures/sim-sawtooth/fig2.d b/tex/src/figures/sim-sawtooth/fig2.dat similarity index 100% rename from tex/src/figures/sim-sawtooth/fig2.d rename to tex/src/figures/sim-sawtooth/fig2.dat diff --git a/tex/src/figures/sim-sawtooth/fig3.d b/tex/src/figures/sim-sawtooth/fig3.dat similarity index 100% rename from tex/src/figures/sim-sawtooth/fig3.d rename to tex/src/figures/sim-sawtooth/fig3.dat diff --git a/tex/src/figures/sim-sawtooth/sim-sawtooth.asy b/tex/src/figures/sim-sawtooth/sim-sawtooth.asy new file mode 100644 index 0000000..2a8032d --- /dev/null +++ b/tex/src/figures/sim-sawtooth/sim-sawtooth.asy @@ -0,0 +1,59 @@ +import wtk_graph; + +size(15cm,10cm,IgnoreAspect); + +scale(Linear, Linear); +real k = 0.05; /* spring constant in N/m */ +real xscale=1e9; +real fscale=1e12; + +void graphSawtooth(string file="datafile", real k, + int xcol=0, int fcol=1, + real xscale=1, real fscale=1, real dx=0, real df=0, + pen p=red) { + file fin=input(file).line(); + real[][] a=fin.dimension(0,0); + a=transpose(a); + real[] x=a[xcol]; + real[] f=a[fcol]; + x = x - f/k; /* Remove cantilever extension */ + graphData(x=x, y=f, xscale=xscale, yscale=fscale, + dx=dx, dy=df, p=p, dots=false); +} + +graphSawtooth("fig1.dat", k=k, xscale=xscale, fscale=fscale, p=psoft); +graphSawtooth("fig2.dat", k=k, xscale=xscale, fscale=fscale, + df=200e-12, p=pmed); +graphSawtooth("fig3.dat", k=k, xscale=xscale, fscale=fscale, + df=400e-12, p=phard); + +//xlimits(xmin, xmax); +//ylimits(ymin, ymax); +xaxis(sLabel("Distance (nm)"), BottomTop, LeftTicks); +yaxis(sLabel("Force (pN)"), LeftRight, RightTicks); +/* +set xrange [-5:250] +set yrange [-10:400] +set ytics 0,100 + +set multiplot + +set size 1,0.42; +set origin 0.0,0.0; +set xlabel 'Extension (nm)' +plot 'fig1.d' using (($1-$2/0.05)*1e9):($2*1e12) + +set size 1,0.29; +set origin 0.0,0.42; +set bmargin 0 +unset xlabel +set xtics format "" +set ylabel 'Force (pN)' +plot 'fig2.d' using (($1-$2/0.05)*1e9):($2*1e12) + +set origin 0.0,0.71; +set bmargin 0 +set xtics format "" +unset ylabel +plot 'fig3.d' using (($1-$2/0.05)*1e9):($2*1e12) +*/ diff --git a/tex/src/sawsim/discussion.tex b/tex/src/sawsim/discussion.tex index 8420223..232dd21 100644 --- a/tex/src/sawsim/discussion.tex +++ b/tex/src/sawsim/discussion.tex @@ -23,7 +23,8 @@ deviation of $25\U{pN}$. \begin{figure} \vspace{-1in} \begin{center} -\subfloat[][]{\includegraphics{figures/sim-sawtooth/fig}\label{fig:sawsim:sim-sawtooth}% +\subfloat[][]{\asyfig{figures/sim-sawtooth/sim-sawtooth}% + \label{fig:sawsim:sim-sawtooth}% }\\ \subfloat[][]{\includegraphics{figures/sim-hist/fig}\label{fig:sawsim:sim-hist}% } @@ -39,12 +40,14 @@ deviation of $25\U{pN}$. connected through the N-C termini\citep{chyan04,carrion-vazquez03}. Detachment from the tip or substrate is assumed to occur at a force of $400\U{pN}$. In experiments, detachments have been observed to - occur at a variety of forces. (b) The distribution of the unfolding - forces from $400$ simulated force curves ($3200$ data points) such - as that shown in (a). The frequency is normalized by the total - number of points, \ie, the height of each bin is equal to the number - of data points in that bin divided by the total number of data - points ($3200$, for this histogram).\label{fig:sawsim:sim-all}} + occur at a variety of forces. For clarity, the green and blue + curves are offset by $200$ and $400\U{pN}$ respectively. (b) The + distribution of the unfolding forces from $400$ simulated force + curves ($3200$ data points) such as that shown in (a). The frequency + is normalized by the total number of points, \ie, the height of each + bin is equal to the number of data points in that bin divided by the + total number of data points ($3200$, for this + histogram).\label{fig:sawsim:sim-all}} \end{center} \end{figure}