Cleaned up graph.

This commit is contained in:
Neil 2023-03-25 00:05:43 -07:00
parent 09cd40399d
commit 15caae5b40

View File

@ -275,7 +275,8 @@ int main(void) {
/*printf("set terminal png transparent truecolor\n"
"set output \"kjv.png\"\n");*/
/* https://stackoverflow.com/a/12601553 */
printf("set terminal pngcairo dashed transparent truecolor\n"
printf("set terminal pngcairo dashed transparent truecolor"
" size 840, 480 fontscale 1\n"
"set output \"kjv.png\"\n");
printf("$Data <<EOD\n"
"# date, verse, words, set / %zu, source\n", no_total);
@ -315,6 +316,12 @@ int main(void) {
"plot $Data using 1:($3)*100/%zu with fillsteps lw 2 title \"set\", \\\n"
"$Data using 1:($4)*100/%zu with steps lw 1 title \"cumulative\"\n",
no_total, no_total);*/
/*w fillsteps fs pattern 14 lc "black" dt 3, \*/
/*#set timefmt "%Y-%m-%d"
# (dy=$4*100/789633,total=total+dy,total-dy/2.): \
# w fillsteps fs pattern 14 lc "black" dt 3, \
# set xrange [:] noextend*/
printf("EOD\n"
"# theozh https://stackoverflow.com/a/75466214/2472827\n"
"# get a unique list from datablock\n"
@ -325,6 +332,12 @@ int main(void) {
"stats $Data u (Uniqs=addToList(Uniqs,5)) nooutput\n"
"Uniq(i) = word(Uniqs,i)\n"
"getIndex(s) = sum [_i=1:words(Uniqs)] s eq word(Uniqs,_i) ? _i : 0\n"
"\n"
"stats $Data u 3 nooutput\n"
"cumsum = STATS_sum\n"
"stats $Data u 4 nooutput\n"
"setsum = STATS_sum\n"
"\n"
"myTimeFmt = \"%%Y-%%m-%%d\"\n"
"set format x myTimeFmt timedate\n"
"set xtics format myTimeFmt rotate by -30\n"
@ -333,21 +346,30 @@ int main(void) {
"set key out reverse Left noautotitle\n"
"set style fill solid 0.5\n"
"unset border\n"
"set autoscale xfix # max? hack: can't get x to extend further\n"
"\n"
"set label sprintf(\"%%u cumulative words (duplicate verses counted)\","
" cumsum) center at graph 0.5, first cumsum*100/%zu offset 0,0.5\n"
"set label sprintf(\"%%u unique KJV verse words memorized\", setsum) "
"center at graph 0.5, first setsum*100/%zu offset 0,0.5\n"
"\n"
"plot \\\n"
" cumsum*100/%zu w l lc \"grey\" dt 2 lw 1, \\\n"
" total=0 $Data u"
" (timecolumn(1,myTimeFmt)):(dy=$3*100/%zu,total=total+dy) \\\n"
" w steps lc \"grey\" dt 2, \\\n" /* `pngcairo` has trouble :[. */
" w steps lc \"grey\" dt 2 lw 1, \\\n" /* `pngcairo` has trouble :[. */
" total=0 $Data u"
" (timecolumn(1,myTimeFmt)):(dy=$4*100/%zu,total=total+dy) \\\n"
" w steps lc \"black\" dt 3, \\\n"
" w steps lc \"black\" dt 1 lw 1, \\\n"
" setsum*100/%zu w l lc \"black\" dt 1 lw 1, \\\n"
" total=0 '' u \\\n"
" (timecolumn(1,myTimeFmt)): \\\n"
" (dy=$4*100/%zu,total=total+dy,total-dy/2.): \\\n"
" (dy=$4*100/%zu,total=total+dy,total/2.): \\\n"
" (43200): \\\n"
" (dy/2.): \\\n"
" (getIndex(strcol(5))) w boxxy lc var, \\\n"
" (total/2.): \\\n"
" (getIndex(strcol(5))) w boxxy lc var lw 1, \\\n"
" for [i=1:words(Uniqs)] keyentry w boxxy lc i ti Uniq(i)\n",
no_total, no_total, no_total);
no_total, no_total, no_total, no_total, no_total, no_total, no_total);
goto finally;
catch:
success = EXIT_FAILURE;