From 9cebb69723e9431eea2f09824d7ae58fe5888554 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Fri, 30 Apr 2010 21:03:37 -0400 Subject: [PATCH] Added histrograms to v-dep-sd, and legends to both v-dep* graphs. They also get a nice dashed line highlighting the histogram source data. --- tex/src/figures/asy/wtk_graph.asy | 28 +++++++++ tex/src/figures/v-dep/v-dep-sd.asy | 99 ++++++++++++++++-------------- tex/src/figures/v-dep/v-dep.asy | 12 +++- 3 files changed, 89 insertions(+), 50 deletions(-) diff --git a/tex/src/figures/asy/wtk_graph.asy b/tex/src/figures/asy/wtk_graph.asy index fff4aa5..778252b 100644 --- a/tex/src/figures/asy/wtk_graph.asy +++ b/tex/src/figures/asy/wtk_graph.asy @@ -1,5 +1,6 @@ import graph; import palette; +import stats; real fsize=10; @@ -64,6 +65,33 @@ void fitFile(picture pic=currentpicture, string file="fitparamfile", } } +void histFile(picture pic=currentpicture, string file="datafile", + int bin_col=0, int count_col=1, + real bin_scale=1, real count_scale=1, real low=-infinity, + pen fillpen=red, pen drawpen=nullpen, bool bars=false, + string t="Title") { + file fin = input(file).line(); + real[][] a = fin.dimension(0,0); + a = transpose(a); + real[] bins = a[bin_col] * bin_scale; + real[] count = a[count_col] * count_scale; + /* Convert bin-center marks to bin-edge marks */ + real bin_width = bins[1]-bins[0]; + bins = bins - bin_width / 2; /* shift centers to the left */ + bins.push(bins[bins.length-1]+bin_width); /* add terminal edge on right */ + /* Normalize counts -> frequency */ + real total = sum(count); + count = count / total; + if (t != "Title") { + histogram(pic=pic, bins=bins, count=count, low=low, + fillpen=fillpen, drawpen=drawpen, bars=bars, + legend=sLabel(t,extra_spaces=1)); + } else { + histogram(pic=pic, bins=bins, count=count, low=low, + fillpen=fillpen, drawpen=drawpen, bars=bars); + } +} + real[] identity_zfn(real[] z) { return z; } diff --git a/tex/src/figures/v-dep/v-dep-sd.asy b/tex/src/figures/v-dep/v-dep-sd.asy index b578767..82eb5ba 100644 --- a/tex/src/figures/v-dep/v-dep-sd.asy +++ b/tex/src/figures/v-dep/v-dep-sd.asy @@ -1,8 +1,12 @@ import wtk_graph; -size(15cm,10cm,IgnoreAspect); -scale(Log, Linear); +//size(15cm, 10cm, IgnoreAspect); + +picture sd; +size(sd, 13cm, 5cm, IgnoreAspect); + +scale(sd, Log, Linear); real xscale=1e9; real yscale=1e12; @@ -11,55 +15,56 @@ real fn_logxliny(real x, real[] params) { return params[0] * log10(x) + params[1]; } -graphFile("v_dep-5e-5_0.1e-9/v_dep", ycol=2, xscale=xscale, yscale=yscale, - p=psoft, - t="$k_{u0}=5\E{-5}\U{s$^-1$}, \Delta x_u=0.100\U{nm}", dots=true); -graphFile("v_dep-1e-5_0.225e-9/v_dep", ycol=2, xscale=xscale, yscale=yscale, - p=pmed, - t="$k_{u0}=1\E{-5}\U{s$^-1$}, \Delta x_u=0.225\U{nm}", dots=true); -graphFile("v_dep-5e-5_0.225e-9/v_dep", ycol=2, xscale=xscale, yscale=yscale, - p=phard, - t="$k_{u0}=5\E{-5}\U{s$^-1$}, \Delta x_u=0.225\U{nm}", dots=true); -fitFile("v_dep-5e-5_0.1e-9/v_dep-sd.fit.dat", f=fn_logxliny, +graphFile(sd, "v_dep-5e-5_0.1e-9/v_dep", ycol=2, + xscale=xscale, yscale=yscale, p=psoft, + t="$k_{u0}=5\E{-5}\U{s$^{-1}$}$, $\Delta x_u=0.100\U{nm}$", + dots=true); +graphFile(sd, "v_dep-1e-5_0.225e-9/v_dep", ycol=2, + xscale=xscale, yscale=yscale, p=pmed, + t="$k_{u0}=1\E{-5}\U{s$^{-1}$}$, $\Delta x_u=0.225\U{nm}$", + dots=true); +graphFile(sd, "v_dep-5e-5_0.225e-9/v_dep", ycol=2, + xscale=xscale, yscale=yscale, p=phard, + t="$k_{u0}=5\E{-5}\U{s$^{-1}$}$, $\Delta x_u=0.225\U{nm}$", + dots=true); +fitFile(sd, "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("v_dep-1e-5_0.225e-9/v_dep-sd.fit.dat", f=fn_logxliny, +fitFile(sd, "v_dep-1e-5_0.225e-9/v_dep-sd.fit.dat", f=fn_logxliny, xmin=1e-9, xmax=1e-5, xscale=xscale, yscale=yscale, p=pmed); -fitFile("v_dep-5e-5_0.225e-9/v_dep-sd.fit.dat", f=fn_logxliny, +fitFile(sd, "v_dep-5e-5_0.225e-9/v_dep-sd.fit.dat", f=fn_logxliny, xmin=1e-9, xmax=1e-5, xscale=xscale, yscale=yscale, p=phard); +xequals(sd, x=1e-6*xscale, p=dashed); -label(sLabel("Pulling speed dependence"), point(N),N); -xaxis(sLabel("Pulling speed (nm/s)"),BottomTop,LeftTicks); -yaxis(sLabel("Unfolding force (pN)"),LeftRight,RightTicks); -/* -set size 0.33,0.4 -unset key -set tmargin -1 -set xrange [100:900] -#set yrange [1e-4:1e-1] -unset logscale x -set logscale y -set xtics 100,200 -set ytics format "10^{%L}" -set xtics format "%g" -set xlabel 'Force (pN)' -set ylabel 'Frequency' -set boxwidth 20 -set style data boxes -set style fill solid 0.3 -#set style fill pattern 4 - -# dummy plot to fix some sizing issue... -set origin 1,1 -plot x +xaxis(sd, sLabel("Pulling speed (nm/s)"), BottomTop, LeftTicks); +yaxis(sd, sLabel("Unfolding force (pN)"), LeftRight, RightTicks); +add(sd, legend(sd), point(sd, E), 20E, UnFill); -set origin 0.0,0.6 -plot 'fig4i-5e-5_0.1e-9.hist' using ($1*1e12+10):($2/3200) - -set origin 0.33,0.6 -plot 'fig4i-1e-5_0.225e-9.hist' using ($1*1e12+10):($2/3200) +picture hist_picture(string datafile, + real xmin=-infinity, real xmax=infinity, + real ymin=-infinity, real ymax=infinity) { + picture pic; + size(pic, 4cm, 3cm, IgnoreAspect); + scale(pic, Linear, Log); + histFile(pic, datafile, bin_scale=yscale, low=ymin); + /* ^-- yscale b/c bins are in Force */ + xlimits(pic, xmin, xmax); + ylimits(pic, ymin, ymax); + xaxis(pic, sLabel("Force (pN)"), BottomTop, LeftTicks); + yaxis(pic, sLabel("Frequency"), LeftRight, RightTicks); + return pic; +} -set origin 0.67,0.6 -plot 'fig4i-5e-5_0.225e-9.hist' using ($1*1e12+10):($2/3200) +/* ensure consistent ranges across all histograms */ +real xmin = 100; +real xmax = 900; +real ymin = 1e-4; +real ymax = 1; -unset multiplot -*/ +add(sd.fit(), (0,0), S); +add(hist_picture("fig4i-5e-5_0.1e-9.hist", xmin, xmax, ymin, ymax).fit(), + 4cm*W, N); +add(hist_picture("fig4i-1e-5_0.225e-9.hist", xmin, xmax, ymin, ymax).fit(), + (0,0), N); +add(hist_picture("fig4i-5e-5_0.225e-9.hist", xmin, xmax, ymin, ymax).fit(), + 4cm*E, N); +label(sLabel("Pulling speed width dependence"), point(N)+(0,3cm), N); diff --git a/tex/src/figures/v-dep/v-dep.asy b/tex/src/figures/v-dep/v-dep.asy index da0e02a..8c2b620 100644 --- a/tex/src/figures/v-dep/v-dep.asy +++ b/tex/src/figures/v-dep/v-dep.asy @@ -12,18 +12,24 @@ real fn_logxliny(real x, real[] params) { } graphFile("v_dep-5e-5_0.1e-9/v_dep", xscale=xscale, yscale=yscale, p=psoft, - t="$k_{u0}=5\E{-5}\U{s$^-1$}, \Delta x_u=0.100\U{nm}", dots=true); + t="$k_{u0}=5\E{-5}\U{s$^{-1}$}$, $\Delta x_u=0.100\U{nm}$", + dots=true); graphFile("v_dep-1e-5_0.225e-9/v_dep", xscale=xscale, yscale=yscale, p=pmed, - t="$k_{u0}=1\E{-5}\U{s$^-1$}, \Delta x_u=0.225\U{nm}", dots=true); + t="$k_{u0}=1\E{-5}\U{s$^{-1}$}$, $\Delta x_u=0.225\U{nm}$", + dots=true); graphFile("v_dep-5e-5_0.225e-9/v_dep", xscale=xscale, yscale=yscale, p=phard, - t="$k_{u0}=5\E{-5}\U{s$^-1$}, \Delta x_u=0.225\U{nm}", dots=true); + t="$k_{u0}=5\E{-5}\U{s$^{-1}$}$, $\Delta x_u=0.225\U{nm}$", + 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, xmin=1e-9, xmax=1e-5, xscale=xscale, yscale=yscale, p=pmed); fitFile("v_dep-5e-5_0.225e-9/v_dep.fit.dat", f=fn_logxliny, xmin=1e-9, xmax=1e-5, xscale=xscale, yscale=yscale, p=phard); +xequals(x=1e-6*xscale, p=dashed); label(sLabel("Pulling speed dependence"), point(N), N); xaxis(sLabel("Pulling speed (nm/s)"), BottomTop, LeftTicks); yaxis(sLabel("Unfolding force (pN)"), LeftRight, RightTicks); + +add(legend(), point(E), 20E, UnFill); -- 2.26.2