aboutsummaryrefslogtreecommitdiff
path: root/reproduce/analysis/make/demo-plot.mk
diff options
context:
space:
mode:
Diffstat (limited to 'reproduce/analysis/make/demo-plot.mk')
-rw-r--r--reproduce/analysis/make/demo-plot.mk35
1 files changed, 30 insertions, 5 deletions
diff --git a/reproduce/analysis/make/demo-plot.mk b/reproduce/analysis/make/demo-plot.mk
index c14b83d..a149040 100644
--- a/reproduce/analysis/make/demo-plot.mk
+++ b/reproduce/analysis/make/demo-plot.mk
@@ -18,7 +18,7 @@
# Directory to host outputs
# -------------------------
-a2dir = $(texdir)/tools-per-year
+a2dir = $(texdir)/to-publish
$(a2dir):; mkdir $@
@@ -27,7 +27,7 @@ $(a2dir):; mkdir $@
# Table for Figure 1C of Menke+20
# -------------------------------
-a2mk20f1c = $(a2dir)/columns.txt
+a2mk20f1c = $(a2dir)/tools-per-year.txt
$(a2mk20f1c): $(mk20tab3) | $(a2dir)
# Remove the (possibly) produced figure that is created from this
@@ -35,12 +35,37 @@ $(a2mk20f1c): $(mk20tab3) | $(a2dir)
# multiple files with a fixed prefix.
rm -f $(tikzdir)/figure-tools-per-year*
+ # Write the column metadata in a temporary file name (appending
+ # '.tmp' to the actual target name). Once all steps are done, it is
+ # renamed to the final target. We do this because if there is an
+ # error in the middle, Make will not consider the job to be
+ # complete and will stop here.
+ echo "# Data of plot showing fraction of papers that mentioned software tools" > $@.tmp
+ echo "# per year to demonstrate the features of Maneage (MANaging data linEAGE)." >> $@.tmp
+ >> $@.tmp
+ echo "# Raw data taken from Menke+2020 (https://doi.org/10.1101/2020.01.15.908111)." \
+ >> $@.tmp
+ echo "# " >> $@.tmp
+ echo "# Column 1: YEAR [count, u16] Publication year of papers." \
+ >> $@.tmp
+ echo "# Column 2: WITH_TOOLS [frac, f32] Fraction of papers mentioning software tools." \
+ >> $@.tmp
+ echo "# Column 3: NUM_PAPERS [count, u32] Total number of papers studied in that year." \
+ >> $@.tmp
+ echo "# " >> $@.tmp
+ $(call print-copyright, $@.tmp)
+
+
# Find the maximum number of papers.
awk '!/^#/{all[$$1]+=$$2; id[$$1]+=$$3} \
END{ for(year in all) \
- print year, 100*id[year]/all[year], all[year] \
+ printf("%-7d%-10.3f%d\n", year, 100*id[year]/all[year], \
+ all[year]) \
}' $< \
- > $@
+ >> $@.tmp
+
+ # Write it into the final target
+ mv $@.tmp $@
@@ -50,7 +75,7 @@ $(a2mk20f1c): $(mk20tab3) | $(a2dir)
$(mtexdir)/demo-plot.tex: $(a2mk20f1c) $(pconfdir)/demo-year.conf
# Find the first year (first column of first row) of data.
- v=$$(awk 'NR==1{print $$1}' $(a2mk20f1c))
+ v=$$(awk '!/^#/ && c==0{c++; print $$1}' $(a2mk20f1c))
echo "\newcommand{\menkefirstyear}{$$v}" > $@
# Find the number of rows in the plotted table.