<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>fs4fd &amp;mdash; bs2facdev</title>
    <link>https://write.as/bs2facdev/tag:fs4fd</link>
    <description></description>
    <pubDate>Mon, 24 Aug 2026 12:35:59 +0000</pubDate>
    <item>
      <title>Racket Plot: Faceted View of Questionnaire Data</title>
      <link>https://write.as/bs2facdev/racket-plot-faceted-view-of-questionnaire-data?pk_campaign=rss-feed</link>
      <description>&lt;![CDATA[This code was broken for a while, the .png-generation portion is still too repetitive. The code  takes questionnaire results and provides a faceted  (R ggplot2-like) view with an .html page that list questions with a visualization of their results for the individual, the individual&#39;s department(faculty), and the department&#39;s(faculty&#39;s) university. &#xA;&#xA;Faceted-like view in Browser&#xA;&#xA;Experience with Racket&#39;s path utilities over the past weeks (and today&#39;s discovery that regexp-replace works with paths!) helped to clean up the part that filters plot images. &#xA;&#xA;Filtering plot images is better with paths&#xA;&#xA;Other work demands attention and time, but it&#39;s awful to leave code in a broken state.&#xA;&#xA;Example of a  generated .png file &#xA;&#xA;code&#xA;!--more--&#xA;lang racket&#xA;&#xA;(define working-directory (build-path (find-system-path &#39;home-dir)&#xA;             &#34;FD&#34;&#xA;             &#34;FD201801H30K-0408-2&#34;))&#xA;&#xA;(make-directory working-directory)&#xA;&#xA;(define page-plot-type &#39;svg)&#xA;(define page-plot-strn (symbol-  string page-plot-type))&#xA;(define shre-bmps-type &#39;png) ;; was bitmap-plot-type&#xA;(define shre-bmps-strn (symbol-  string shre-bmps-type))&#xA;&#xA;(define bmps-dir (symbol-  string shre-bmps-type))&#xA;(make-directory (path-  complete-path bmps-dir working-directory))&#xA;&#xA;(require plot) ;; discrete-histogram, stacked-histogram etc&#xA;(require plot/utils) ;; -  plot-label&#xA;(require scribble/html/html) ;; for output-xml, html and class:&#xA;(require scribble/html) ;; for element&#xA;&#xA;;; set the order of images in output page&#xA;(define bodies &#39;(教員 学科 大学)) ;; Teacher, Department, University&#xA;&#xA;;; short keys and labels for questions and data&#xA;(define quest-symbs &#39;(出席 発言 取組 聞取 資料 時刻 反応 熱意 理解 役立 満足))&#xA;&#xA;;; データを入力し直すところ&#xA;(define ind-als ;;教員の連帯リスト associative list&#xA;  &#39;((nme (教員 TCR スモール 教養)) ;; NaME of BoDy bod 体&#xA;    (smr (2018 02 H30 K)) ;; 学期 SeMesteR&#xA;    (cls (1 68))         ;; 授業、教室 CLasS&#xA;    (dta ((33 28 6 1 0)   ;; データ、DaTA&#xA;&#x9; (8 27 19 9 5)&#xA;&#x9; (8 25 22 12 1)&#xA;&#x9; (37 25 6 0 0)&#xA;&#x9; (21 34 11 2 0)&#xA;&#x9; (49 16 3 0 0)&#xA;&#x9; (47 16 5 0 0)&#xA;&#x9; (56 11 1 0 0)&#xA;&#x9; (25 31 7 5 0)&#xA;&#x9; (17 33 15 2 1)&#xA;&#x9; (19 38 8 2 1)))))&#xA;&#xA;(define dep-als ;;学科 associative list&#xA;  &#39;((nme (学科 DPT 教養 大学))&#xA;    (smr (2018 02 H30 K))&#xA;    (cls (6 276))&#xA;    (dta ((198 59 16 3 0)&#xA;    (39 86 102 26 22)&#xA;    (50 96 90 29 9)&#xA;    (130 91 40 10 4)&#xA;    (98 107 55 12 3)&#xA;    (174 70 26 4 2)&#xA;    (125 95 48 5 3)&#xA;    (161 81 30 2 1)&#xA;    (99 114 45 13 5)&#xA;    (95 105 65 8 3)&#xA;    (89 120 51 9 7)))))&#xA;&#xA;(define uni-als ;;大学&#xA;  &#39;((nme (大学 UVY 南九州 学園))&#xA;    (smr (2018 02 H30 K))&#xA;    (cls (57 2403))&#xA;    (dta ((1679 479 202 31 10)&#xA;     (419 616 974 190 199)&#xA;     (684 822 692 134 65)&#xA;     (1341 670 293 69 28)&#xA;     (1200 695 374 86 42)&#xA;     (1702 480 169 28 17)&#xA;     (1315 652 349 52 33)&#xA;     (1537 585 236 21 19)&#xA;     (938 940 412 73 34)&#xA;     (1328 676 325 43 26)&#xA;     (1172 781 356 55 34)))))&#xA;&#xA;(require plot) ;; discrete-histogram, stacked-histogram etc&#xA;(require plot/utils) ;; -  plot-label&#xA;(require scribble/html/html) ;; for output-xml, html and class:&#xA;(require scribble/html) ;; for element&#xA;&#xA;(define als-ref&#xA;  (lambda (key als)&#xA;    (if (assoc key als)&#xA;       (second (assoc key als))&#xA;       #f)))&#xA;&#xA;(define counts-  percents&#xA;  (lambda (lon) ;; list of numbers&#xA;    (let ((total (apply + lon)))&#xA;    (map (lambda (count)&#xA;&#x9;     ( (/ count total) 100.0))&#xA;&#x9;   lon))))&#xA;&#xA;(define pnt-w-lbl&#xA;  (lambda (x n l (algn &#39;bottom) (sze 8) (pnt-clr 0) (lbel-angl 0))&#xA;    (point-label (vector x n) l&#xA;                #:anchor algn #:size sze&#xA;                #:point-color pnt-clr #:angle lbel-angl)))&#xA;;;  with too many digits #:angle 170 might help&#xA;&#xA;(define vline-to-y&#xA;  (lambda (x y)&#xA;    (lines (map vector (list x x) (list 0 y)))))&#xA;&#xA;(define vline-y1-to-y2&#xA;  (lambda (x y1 y2 (clr 0)) ; y1 and y2 are percents&#xA;    (list&#xA;     (lines (map vector (list x x) (list 0 y1)) #:width 2 #:color clr)&#xA;     (lines (map vector (list x x) (list y1 y2)) #:width 4 #:color clr))))&#xA;&#xA;(define line-label ;; replaces pos-line-label and neg-line-label&#xA;  ;; xlevel percents, 4&#39;s count 5&#39;s count&#xA;  ;; defaults to positive line with anchor &#39;bottom&#xA;  ;;  over-ride anchor with &#39;top fo negative direction&#xA;  (lambda (x p4 p5 c4 c5 (lbl-aln &#39;bottom) (clr 0))&#xA;    ;; points always given with same sign +pos or -neg&#xA;    (let ((p4n5 (+ p4 p5))&#xA;&#x9;  (cnt-lbl (string-join (map number-  string (list (abs c4) (abs c5))) &#34;:&#34;)))&#xA;      (list&#xA;       (pnt-w-lbl x p4n5 (-  plot-label cnt-lbl) lbl-aln)&#xA;       (vline-y1-to-y2 x p4 p4n5 clr))))) ;; 1 is #:color 1 (red)&#xA;&#xA;;; Replaces stck-ngtv-rslts and stck-pstv-rsltrs&#xA;(define stck-rslts&#xA;  (lambda (row #:x (x 5.5) #:algn (algn &#39;bottom) #:clr (clr 1) #:sign (sign +))&#xA;    (let ((cn5 (first row))&#xA;&#x9;   (cn4 (second row))&#xA;;;&#x9;   (x 5.5) ;; #:x-max will be 5.8&#xA;&#x9;   (pcnts (counts-  percents row))&#xA;&#x9;   (pr5 (first pcnts))&#xA;&#x9;   (pr4 (second pcnts)))&#xA;      (line-label x (sign pr4) (sign pr5) (sign cn4) (sign cn5) algn clr))))&#xA;&#x9;   &#xA;(define lines-percents-labels-counts&#xA;  ;; for each row of Question Results&#xA;  ;;  get vline-to-y and pnt-w-lbl ready for plot&#xA;  (lambda (lon)&#xA;    (let ((pcnts (counts-  percents lon))&#xA;&#x9;  (lvels &#39;(5 4 3 2 1))&#xA;&#x9;  (tot-lab (-  plot-label (apply + lon))))&#xA;      (append ;; need a flat list for plot&#xA;       (map (lambda (l p) ;; level percent&#xA;&#x9;      (vline-to-y l p))&#xA;&#x9;    lvels pcnts)&#xA;       (map (lambda (x n l)&#xA;&#x9;      ;; xResponse level nNumber point lLabel&#xA;&#x9;      (pnt-w-lbl x n l))&#xA;&#x9;    lvels pcnts&#xA;&#x9;    (map (lambda (s) (string-append s &#34;/&#34; tot-lab))&#xA;&#x9;&#x9; (map -  plot-label lon)))))))&#xA;&#xA;;; get data ready for lines-percents-labels-counts&#xA;(define dta-  Qss-Als&#xA;  (lambda (Qss Als) ;; Question Symbols, A-list&#xA;    (map list Qss (als-ref &#39;dta Als))))&#xA;&#xA;(define plot-bod-als-to-percentlines-countlabels&#xA;  (lambda (BodAls  Qsyms #:kind (ext &#39;svg))&#xA;    ;; get orginal result data into associative list: QR-als&#xA;    (let ((QR-als (dta-  Qss-Als Qsyms BodAls))&#xA;          (smr (string-join (map -  plot-label (als-ref &#39;smr BodAls)) &#34;&#34;))&#xA;           (bod (-  plot-label (car (als-ref &#39;nme BodAls)))))&#xA;      (define lines-percents-titled&#xA;&#x9;(lambda (QR)&#xA;&#x9;  (let ((ttl (string-append smr &#34;  &#34; bod &#34;:&#34; (-  plot-label (car QR))))&#xA;&#x9;&#x9; (plt-ttl (string-append ttl &#34;  &#34;&#xA;                                        (string-join (map -  plot-label&#xA;                                                         (als-ref &#39;cls BodAls)) &#34;T/&#34;)&#xA;                                        &#34;S   Avg: &#34;&#xA;                                        (-  plot-label&#xA;                                         (round (/ (cadr (als-ref &#39;cls BodAls))&#xA;                                                  (car (als-ref &#39;cls BodAls)))))&#xA;                                        &#34;S&#34;))&#xA;                 (fle-name (build-path working-directory ; remove space from ttle for filename&#xA;                                      (string-append  (regexp-replace &#34;  | &#34; ttl &#34;&#34;)&#xA;                                                    (-  plot-label (car (als-ref &#39;smr BodAls)))&#xA;                                                    (-  plot-label (cadr (als-ref &#39;smr BodAls)))&#xA;                                                    &#34;.&#34;&#xA;                                                    (symbol-  string ext))))) ;; use page-plot-type later&#xA;            (plot (list (hrule 0 #:color 0) ;; need this for stck-ngtv-rslts&#xA;&#x9;&#x9;&#x9;(lines-percents-labels-counts (cadr QR))&#xA;&#x9;&#x9;&#x9;(stck-rslts (cadr QR))&#xA;&#x9;&#x9;&#x9;(stck-rslts (reverse (cadr QR)) #:algn &#39;top #:clr 0 #:sign -))&#xA;&#x9;&#x9;#:x-min .5  #:x-max 5.9&#xA;&#x9;&#x9;#:y-min -30 #:y-max 115&#xA;&#x9;&#x9;#:width 400 #:height 250&#xA;&#x9;&#x9;#:x-label &#34;levels&#34; #:y-label &#34;percent&#34;&#xA;&#x9;&#x9;#:title plt-ttl&#xA;&#x9;&#x9;#:out-file fle-name&#xA; &#x9;&#x9;#:out-kind ext))))&#xA;      (map lines-percents-titled QR-als))))&#xA;&#xA;(define anket-reslt-alist-  line-labl-chrts&#xA;  ;; call plot-bod-als-to with ink-minimizing parameters&#xA;  (lambda (als Qsymbs)&#xA;    (parameterize ((plot-tick-size 3)&#xA;&#x9;&#x9;   (plot-x-far-axis? #f)&#xA;&#x9;&#x9;   (plot-y-far-axis? #f))&#xA;      (plot-bod-als-to-percentlines-countlabels als Qsymbs))))&#xA;&#xA;(define working-files (directory-list working-directory)) ;; was dir-lis-strs&#xA;;; &#34;.svg&#34; working-directory&#xA;(define get-plot-files ;; was mthcd-files&#xA;  (lambda (ext-str img-pths)&#xA;    (filter (lambda (p) (path-has-extension? p ext-str))&#xA;&#x9;    img-pths)))&#xA;&#xA;(define page-plot-files (get-plot-files page-plot-strn working-files))&#xA;&#xA;(define body-quest-plot-name ; was bod-img&#xA;  (lambda (B Q) ; Body Question&#xA;    (let ((Brx (regexp (symbol-  string B)))&#xA;&#x9;  (Qrx (regexp (symbol-  string Q))))&#xA;      (path-  string&#xA;       (car&#xA;&#x9;(filter (lambda (p) (regexp-match Brx p))&#xA;&#x9;&#x9;(filter (lambda (p)&#xA;&#x9;&#x9;&#x9;  (regexp-match Qrx p))&#xA;&#x9;&#x9;&#x9;page-plot-files)))))))&#xA;(define questions &#39;(&#xA;(出席 &#x9;&#34;私はこの授業によく出席した&#34;                                              学生取組)&#xA;(発言 &#x9;&#34;私は授業内容について質問や発言した&#34;                                      学生取組)&#xA;(取組 &#x9;&#34;私はこの科目に積極的に取り組んだ(予習と復習した)&#34;                      学生取組)&#xA;(聞取 &#x9;&#34;教員の声は聞き取りやすかった。&#34;                                          教員実施)&#xA;(資料 &#x9;&#34;教員の板書(またはPPT・配布資料など)は読みやすかった(見やすかった)&#34;   教員実施)&#xA;(時刻 &#x9;&#34;教員は授業の開始・終了の時刻を守ろうとしていた&#34;                          教員実施)&#xA;(反応 &#x9;&#34;教員は学生の反応を確かめながら授業を進めていた&#34;                          教員実施)&#xA;(熱意 &#x9;&#34;教員は熱意を持って授業をしていた&#34;                                        教員実施)&#xA;(理解 &#x9;&#34;私はこの授業内容を理解できた&#34;                                            総合評価)&#xA;(役立 &#x9;&#34;私はこの授業で学んだ内容はなんらかの形で将来的に役立つと感じた&#34;          総合評価)&#xA;(満足 &#x9;&#34;私は総合的に判断してこの授業で満足が得られた&#34;                            総合評価)))&#xA;&#xA;(define responses &#39;((5 特に   &#34;特にそう思う&#34;       &#34;very much&#34;  &#34;I really think so&#34;)&#xA;&#x9;&#x9;    (4 多少   &#34;多少そう思う&#34;&#x9;   &#34;fairly much&#34;  &#34;I somewhat think so&#34;)&#xA;&#x9;&#x9;    (3 どちも &#34;どちらともいえない&#34; &#34;neither&#34;  &#34;I can&#39;t say either way&#34;)&#xA;&#x9;&#x9;    (2 あまり &#34;あまりそう思わない&#34; &#34;not much&#34;  &#34;I do not think so much&#34;)&#xA;&#x9;&#x9;    (1 全く   &#34;全くそう思わない&#34;   &#34;not at all&#34;  &#34;I do not think so at all&#34;)))&#xA;;; (sort responses #:key car &lt;)&#xA;&#xA;(define bdy-rslt-img&#xA;  (lambda (imge-file)&#xA;    (element &#39;img class: &#34;result-image&#34; src: imge-file)))&#xA;&#xA;(define Qsym-Bdys-rslt-imgs&#xA;;; Question symbol, list of body symbols&#xA;  (lambda (qsym bdys) ;; extensiong taking care of aith get-page-plots&#xA;    (map (lambda (bdy-rx) ; Racket style define vs. cute lambda?&#xA;&#x9;   (body-quest-plot-name bdy-rx qsym))&#xA;&#x9; bdys)))&#xA;&#xA;(define rslt-img-div&#xA;  (lambda (rslt-imgs)&#xA;    (element &#39;div class: &#34;result-images&#34;&#xA;&#x9;     (map bdy-rslt-img rslt-imgs))))&#xA;&#xA;;; (output-xml (map bdy-rslt-img (Qsym-Bdys-rslt-imgs &#39;資料 bodies)))&#xA;;; img class=&#34;result-image&#34; src=&#34;20182H30K教員:資料20182.svg&#34; /img class=&#34;result-image&#34; src=&#34;20182H30K学科:資料20182.svg&#34; /img class=&#34;result-image&#34; src=&#34;20182H30K大学:資料20182.svg&#34; /&#xA;&#xA;(define Qsym-  Qli&#xA;  ;; Question-Symbol to Question item liQ/li&#xA;  (lambda (sym Qs)&#xA;    (element &#39;li class: &#34;ques-txt-ja&#34;&#xA;&#x9;     (als-ref sym Qs))))&#xA;&#xA;(define Q-li-Rs-div&#xA;  ;; get Qli and image links ready for output-xml&#xA;  (lambda (sym ext) ;; To do, remove ext, not needed with new Qsym-Bdys-rslt-imgs def&#xA;    (list&#xA;     (Qsym-  Qli sym questions)&#xA;     (rslt-img-div (Qsym-Bdys-rslt-imgs sym bodies)))))&#xA;&#xA;(define Qs-w-Rs-  ol&#xA;  ;; for output-xml get Qli and Rimages into ordered list&#xA;  (lambda (syms ext)&#xA;    (element &#39;ol class: &#34;questions-with-results&#34;&#xA;&#x9;     (map (lambda (sym) (Q-li-Rs-div sym ext)) syms))))&#xA;&#xA;(define resp-levl-defn&#xA;  (lambda (rsp-row)&#xA;     (element &#39;li class: &#34;response-item&#34;&#xA;&#x9;      (string-join&#xA;&#x9;       (map -  plot-label (list&#xA;&#x9;&#x9;&#x9;&#x9;  (car rsp-row)&#xA;&#x9;&#x9;&#x9;&#x9;  &#34;. &#34;&#xA;&#x9;&#x9;&#x9;&#x9;  (caddr rsp-row)))&#xA;&#x9;       &#34;&#34;))))&#xA;&#xA;(define resp-levl-list&#xA;  (lambda (defns)&#xA;    (element &#39;ol class: &#34;response-levels&#34;&#xA;&#x9;     (map resp-levl-defn (sort responses #:key car &lt;)))))&#xA;&#xA;(define output-QsRs-page&#xA;  (lambda (als plt-ext)&#xA;    (let ((yr-sr (string-join (map -  plot-label (als-ref &#39;smr als)) &#34;&#34;))&#xA;&#x9;   ;;year semetsr&#xA;&#x9;   (pge-ttl (string-append &#34;FD アンケート結果 &#34; yr-sr)))&#xA;      (call-with-output-file (build-path working-directory&#xA;                                        (string-append &#34;FD-Anketo-Questions-Result-&#34; yr-sr &#34;.html&#34;)) #:exists &#39;truncate&#xA;&#x9;&#x9;&#x9;     (lambda (out)&#xA;&#x9;&#x9;&#x9;       (output-xml (xhtml&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;    (head (title pge-ttl)&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&#x9;  (meta http-equiv: &#34;Content-Type&#34; content: &#34;text/html;charset=utf-8&#34;)&#xA;                                                  (map style (list ;; saves ink/color to map style over a list of strings&#xA;                                                              &#34;@page { size: 210mm 297mm; margin: 4mm 4mm 6mm 4mm; }&#34;                       &#xA;                                                              &#34;h2 {margin-top: 10px; margin-bottom: 10px; font-size: 12pt;} &#34;&#xA;                                                              &#34;h3 {margin-top: 8px; margin-bottom: 8px; font-size: 10pt; }&#34;                 &#x9;&#x9;&#x9;&#x9;&#x9;    &#xA;                                                              &#34;ol.response-levels {margin-left: 0em; padding-left: 0; font-size: 11pt;&#34;&#xA;                                                              &#34;li.response-item {display: inline; margin-left: .5em; }&#34;       &#xA;                                                              &#34;li {page-break-inside: avoid; } &#34;                       &#xA;                                                              &#34;li.ques-txt-ja { margin-left: -.7em; font-size: 13pt; }&#34;&#xA;                                                              &#34;div.result-images {width: 100%;} &#34;                       &#xA;                                                              &#34;img.result-image { margin: 5px 0 10px 0 ; width:32%;  }&#34;)))&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;    (body&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;     (h2 pge-ttl)&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;     (h3 &#34;回答数字の文&#34;)&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;     (resp-levl-list responses)&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;     (h3 &#34;設問の文と結果の図&#34;)&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;     (Qs-w-Rs-  ol quest-symbs plt-ext)&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;     ;; (element &#39;ol class: &#34;questions&#34;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;     ;; &#x9;   (map (lambda (sym) (Qsym-  Qli sym questions)) quest-symbs))&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;     ))&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;   out))))))&#xA;&#xA;(define generate-plot-images-and-html-page&#xA;  (lambda (list-of-alists plt-ext)&#xA;    (map (lambda (als)&#xA;&#x9;   (anket-reslt-alist-  line-labl-chrts als quest-symbs))&#xA;&#x9; list-of-alists)&#xA;    (output-QsRs-page (last list-of-alists) plt-ext)))&#xA;&#xA;  (define write-plot-images-html-page-to&#xA;  (lambda (pth lst-of-alsts plt-ext)&#xA;      (generate-plot-images-and-html-page&#xA;       lst-of-alsts plt-ext)))&#xA;&#xA;;; plot-type plot extension plt-ext&#xA; (write-plot-images-html-page-to working-directory (list ind-als dep-als uni-als) (symbol-  string page-plot-type))&#xA;&#xA;;; End html page with .svg plots&#xA;;; Start png plots to png directory&#xA;&#xA;(define plot-bod-als-to-percentlines-countlabels-to-bmps&#xA;  (lambda (BodAls  Qsyms #:kind (ext &#39;svg))&#xA;    ;; get orginal result data into associative list: QR-als&#xA;    (let ((QR-als (dta-  Qss-Als Qsyms BodAls))&#xA;          (smr (string-join (map -  plot-label (als-ref &#39;smr BodAls)) &#34;&#34;))&#xA;           (bod (-  plot-label (car (als-ref &#39;nme BodAls)))))&#xA;      (define lines-percents-titled&#xA;&#x9;(lambda (QR)&#xA;&#x9;  (let ((ttl (string-append smr &#34;  &#34; bod &#34;:&#34; (-  plot-label (car QR))))&#xA;&#x9;&#x9; (plt-ttl (string-append ttl &#34;  &#34;&#xA;                                        (string-join (map -  plot-label&#xA;                                                         (als-ref &#39;cls BodAls)) &#34;T/&#34;)&#xA;                                        &#34;S   Avg: &#34;&#xA;                                        (-  plot-label&#xA;                                         (round (/ (cadr (als-ref &#39;cls BodAls))&#xA;                                                  (car (als-ref &#39;cls BodAls)))))&#xA;                                        &#34;S&#34;))&#xA;                 (fle-name (build-path working-directory shre-bmps-strn ; remove space from ttle for filename&#xA;                                      (string-append  (regexp-replace* &#34;  | &#34; ttl &#34;&#34;)&#xA;                                                    (-  plot-label (car (als-ref &#39;smr BodAls)))&#xA;                                                    (-  plot-label (cadr (als-ref &#39;smr BodAls)))&#xA;                                                    &#34;.&#34;&#xA;                                                    (symbol-  string ext))))) ;; use page-plot-type later&#xA;            (plot (list (hrule 0 #:color 0) ;; need this for stck-ngtv-rslts&#xA;&#x9;&#x9;&#x9;(lines-percents-labels-counts (cadr QR))&#xA;&#x9;&#x9;&#x9;(stck-rslts (cadr QR))&#xA;&#x9;&#x9;&#x9;(stck-rslts (reverse (cadr QR)) #:algn &#39;top #:clr 0 #:sign -))&#xA;&#x9;&#x9;#:x-min .5  #:x-max 5.9&#xA;&#x9;&#x9;#:y-min -30 #:y-max 115&#xA;&#x9;&#x9;#:width 400 #:height 250&#xA;&#x9;&#x9;#:x-label &#34;levels&#34; #:y-label &#34;percent&#34;&#xA;&#x9;&#x9;#:title plt-ttl&#xA;&#x9;&#x9;#:out-file fle-name&#xA; &#x9;&#x9;#:out-kind ext))))&#xA;      (map lines-percents-titled QR-als))))&#xA;&#xA;(define anket-reslt-alist-  line-labl-chrts-w-ext&#xA;  (lambda (als Qsymbs #:ext (ext &#39;png))&#xA;    (parameterize ((plot-tick-size 3)&#xA;&#x9;&#x9;   (plot-x-far-axis? #f)&#xA;&#x9;&#x9;   (plot-y-far-axis? #f))&#xA;      (plot-bod-als-to-percentlines-countlabels-to-bmps als Qsymbs #:kind ext))))&#xA;&#xA;(define write-ind-dep-uni-result-plots&#xA;  (lambda (ext-dir-sym)&#xA;      (map (lambda (als)&#xA;&#x9;     (anket-reslt-alist-  line-labl-chrts-w-ext als quest-symbs #:ext ext-dir-sym))&#xA;&#x9;   (list ind-als dep-als uni-als))&#xA;    ))&#xA;      ;;(change-directory-to wrk-dir))))&#xA;&#xA;(write-ind-dep-uni-result-plots shre-bmps-type)&#xA;&#xA;  previous attempt: the basis of this script&#xA;     https://write.as/bs2facdev/racket-plot-stacked-lines-labeled-positive-and-negative&#xA;  #Scheme #Racket #FS4FT #FS4FD #facdev #FacultyDevelopment #DataVisualizatoin #アンケート #データ視覚化 #graph #plot #DataVisualization]]&gt;</description>
      <content:encoded><![CDATA[<p>This code was broken for a while, the .png-generation portion is still too repetitive. The code  takes questionnaire results and provides a faceted  (R ggplot2-like) view with an .html page that list questions with a visualization of their results for the individual, the individual&#39;s department(faculty), and the department&#39;s(faculty&#39;s) university.</p>

<p><img src="https://i.snap.as/yidYRIe.png" alt="Faceted-like view in Browser" title="Faceted-like view in Browser"/></p>

<p>Experience with Racket&#39;s path utilities over the past weeks (and today&#39;s discovery that <code>regexp-replace</code> works with paths!) helped to clean up the part that filters plot images.</p>

<p><img src="https://i.snap.as/d3eCE6L.png" alt="Filtering plot images is better with paths" title="Filtering plot images is better with paths"/></p>

<p>Other work demands attention and time, but it&#39;s awful to leave code in a broken state.</p>

<p><img src="https://i.snap.as/T2D5VPK.image" alt="Example of a  generated .png file " title="Example of a  generated .png file "/></p>

<h3 id="code">code</h3>



<pre><code>#lang racket

(define working-directory (build-path (find-system-path &#39;home-dir)
             &#34;FD&#34;
             &#34;FD201801H30K-0408-2&#34;))

(make-directory* working-directory)

(define page-plot-type &#39;svg)
(define page-plot-strn (symbol-&gt;string page-plot-type))
(define shre-bmps-type &#39;png) ;; was bitmap-plot-type
(define shre-bmps-strn (symbol-&gt;string shre-bmps-type))

(define bmps-dir (symbol-&gt;string shre-bmps-type))
(make-directory* (path-&gt;complete-path bmps-dir working-directory))

(require plot) ;; discrete-histogram, stacked-histogram etc
(require plot/utils) ;; -&gt;plot-label
(require scribble/html/html) ;; for output-xml, html and class:
(require scribble/html) ;; for element

;; set the order of images in output page
(define bodies &#39;(教員 学科 大学)) ;; Teacher, Department, University

;; short keys and labels for questions and data
(define quest-symbs &#39;(出席 発言 取組 聞取 資料 時刻 反応 熱意 理解 役立 満足))

;; データを入力し直すところ
(define ind-als ;;教員の連帯リスト associative list
  &#39;((nme (教員 TCR スモール 教養)) ;; NaME of BoDy bod 体
    (smr (2018 02 H30 K)) ;; 学期 SeMesteR
    (cls (1 68))         ;; 授業、教室 CLasS
    (dta ((33 28 6 1 0)   ;; データ、DaTA
	 (8 27 19 9 5)
	 (8 25 22 12 1)
	 (37 25 6 0 0)
	 (21 34 11 2 0)
	 (49 16 3 0 0)
	 (47 16 5 0 0)
	 (56 11 1 0 0)
	 (25 31 7 5 0)
	 (17 33 15 2 1)
	 (19 38 8 2 1)))))

(define dep-als ;;学科 associative list
  &#39;((nme (学科 DPT 教養 大学))
    (smr (2018 02 H30 K))
    (cls (6 276))
    (dta ((198 59 16 3 0)
    (39 86 102 26 22)
    (50 96 90 29 9)
    (130 91 40 10 4)
    (98 107 55 12 3)
    (174 70 26 4 2)
    (125 95 48 5 3)
    (161 81 30 2 1)
    (99 114 45 13 5)
    (95 105 65 8 3)
    (89 120 51 9 7)))))

(define uni-als ;;大学
  &#39;((nme (大学 UVY 南九州 学園))
    (smr (2018 02 H30 K))
    (cls (57 2403))
    (dta ((1679 479 202 31 10)
     (419 616 974 190 199)
     (684 822 692 134 65)
     (1341 670 293 69 28)
     (1200 695 374 86 42)
     (1702 480 169 28 17)
     (1315 652 349 52 33)
     (1537 585 236 21 19)
     (938 940 412 73 34)
     (1328 676 325 43 26)
     (1172 781 356 55 34)))))

(require plot) ;; discrete-histogram, stacked-histogram etc
(require plot/utils) ;; -&gt;plot-label
(require scribble/html/html) ;; for output-xml, html and class:
(require scribble/html) ;; for element


(define als-ref
  (lambda (key als)
    (if (assoc key als)
       (second (assoc key als))
       #f)))

(define counts-&gt;percents
  (lambda (lon) ;; list of numbers
    (let ((total (apply + lon)))
    (map (lambda (count)
	     (* (/ count total) 100.0))
	   lon))))

(define pnt-w-lbl
  (lambda (x n l (algn &#39;bottom) (sze 8) (pnt-clr 0) (lbel-angl 0))
    (point-label (vector x n) l
                #:anchor algn #:size sze
                #:point-color pnt-clr #:angle lbel-angl)))
;;  with too many digits #:angle 170 might help

(define vline-to-y
  (lambda (x y)
    (lines (map vector (list x x) (list 0 y)))))

(define vline-y1-to-y2
  (lambda (x y1 y2 (clr 0)) ; y1 and y2 are percents
    (list
     (lines (map vector (list x x) (list 0 y1)) #:width 2 #:color clr)
     (lines (map vector (list x x) (list y1 y2)) #:width 4 #:color clr))))

(define line-label ;; replaces pos-line-label and neg-line-label
  ;; xlevel percents, 4&#39;s count 5&#39;s count
  ;; defaults to positive line with anchor &#39;bottom
  ;;  over-ride anchor with &#39;top fo negative direction
  (lambda (x p4 p5 c4 c5 (lbl-aln &#39;bottom) (clr 0))
    ;; points always given with same sign +pos or -neg
    (let ((p4n5 (+ p4 p5))
	  (cnt-lbl (string-join (map number-&gt;string (list (abs c4) (abs c5))) &#34;:&#34;)))
      (list
       (pnt-w-lbl x p4n5 (-&gt;plot-label cnt-lbl) lbl-aln)
       (vline-y1-to-y2 x p4 p4n5 clr))))) ;; 1 is #:color 1 (red)

;; Replaces stck-ngtv-rslts and stck-pstv-rsltrs
(define stck-rslts
  (lambda (row #:x (x 5.5) #:algn (algn &#39;bottom) #:clr (clr 1) #:sign (sign +))
    (let* ((cn5 (first row))
	   (cn4 (second row))
;;	   (x 5.5) ;; #:x-max will be 5.8
	   (pcnts (counts-&gt;percents row))
	   (pr5 (first pcnts))
	   (pr4 (second pcnts)))
      (line-label x (sign pr4) (sign pr5) (sign cn4) (sign cn5) algn clr))))
	   
(define lines-percents-labels-counts
  ;; for each row of Question Results
  ;;  get vline-to-y and pnt-w-lbl ready for plot
  (lambda (lon)
    (let ((pcnts (counts-&gt;percents lon))
	  (lvels &#39;(5 4 3 2 1))
	  (tot-lab (-&gt;plot-label (apply + lon))))
      (append ;; need a flat list for plot
       (map (lambda (l p) ;; level percent
	      (vline-to-y l p))
	    lvels pcnts)
       (map (lambda (x n l)
	      ;; xResponse level nNumber point lLabel
	      (pnt-w-lbl x n l))
	    lvels pcnts
	    (map (lambda (s) (string-append s &#34;/&#34; tot-lab))
		 (map -&gt;plot-label lon)))))))

;; get data ready for lines-percents-labels-counts
(define dta-&gt;Qss-Als
  (lambda (Qss Als) ;; Question Symbols, A-list
    (map list Qss (als-ref &#39;dta Als))))

(define plot-bod-als-to-percentlines-countlabels
  (lambda (BodAls  Qsyms #:kind (ext &#39;svg))
    ;; get orginal result data into associative list: QR-als
    (let ((QR-als (dta-&gt;Qss-Als Qsyms BodAls))
          (smr (string-join (map -&gt;plot-label (als-ref &#39;smr BodAls)) &#34;&#34;))
           (bod (-&gt;plot-label (car (als-ref &#39;nme BodAls)))))
      (define lines-percents-titled
	(lambda (QR)
	  (let* ((ttl (string-append smr &#34;  &#34; bod &#34;:&#34; (-&gt;plot-label (car QR))))
		 (plt-ttl (string-append ttl &#34;  &#34;
                                        (string-join (map -&gt;plot-label
                                                         (als-ref &#39;cls BodAls)) &#34;T/&#34;)
                                        &#34;S   Avg: &#34;
                                        (-&gt;plot-label
                                         (round (/ (cadr (als-ref &#39;cls BodAls))
                                                  (car (als-ref &#39;cls BodAls)))))
                                        &#34;S&#34;))
                 (fle-name (build-path working-directory ; remove space from ttle for filename
                                      (string-append  (regexp-replace* &#34;  | &#34; ttl &#34;&#34;)
                                                    (-&gt;plot-label (car (als-ref &#39;smr BodAls)))
                                                    (-&gt;plot-label (cadr (als-ref &#39;smr BodAls)))
                                                    &#34;.&#34;
                                                    (symbol-&gt;string ext))))) ;; use page-plot-type later
            (plot (list (hrule 0 #:color 0) ;; need this for stck-ngtv-rslts
			(lines-percents-labels-counts (cadr QR))
			(stck-rslts (cadr QR))
			(stck-rslts (reverse (cadr QR)) #:algn &#39;top #:clr 0 #:sign -))
		#:x-min .5  #:x-max 5.9
		#:y-min -30 #:y-max 115
		#:width 400 #:height 250
		#:x-label &#34;levels&#34; #:y-label &#34;percent&#34;
		#:title plt-ttl
		#:out-file fle-name
 		#:out-kind ext))))
      (map lines-percents-titled QR-als))))

(define anket-reslt-alist-&gt;line-labl-chrts
  ;; call plot-bod-als-to~~ with ink-minimizing parameters
  (lambda (als Qsymbs)
    (parameterize ((plot-tick-size 3)
		   (plot-x-far-axis? #f)
		   (plot-y-far-axis? #f))
      (plot-bod-als-to-percentlines-countlabels als Qsymbs))))


(define working-files (directory-list working-directory)) ;; was dir-lis-strs
;; &#34;.svg&#34; working-directory
(define get-plot-files ;; was mthcd-files
  (lambda (ext-str img-pths)
    (filter (lambda (p) (path-has-extension? p ext-str))
	    img-pths)))

(define page-plot-files (get-plot-files page-plot-strn working-files))

(define body-quest-plot-name ; was bod-img
  (lambda (B Q) ; Body Question
    (let ((Brx (regexp (symbol-&gt;string B)))
	  (Qrx (regexp (symbol-&gt;string Q))))
      (path-&gt;string
       (car
	(filter (lambda (p) (regexp-match Brx p))
		(filter (lambda (p)
			  (regexp-match Qrx p))
			page-plot-files)))))))
(define questions &#39;(
(出席 	&#34;私はこの授業によく出席した&#34;                                              学生取組)
(発言 	&#34;私は授業内容について質問や発言した&#34;                                      学生取組)
(取組 	&#34;私はこの科目に積極的に取り組んだ(予習と復習した)&#34;                      学生取組)
(聞取 	&#34;教員の声は聞き取りやすかった。&#34;                                          教員実施)
(資料 	&#34;教員の板書(またはPPT・配布資料など)は読みやすかった(見やすかった)&#34;   教員実施)
(時刻 	&#34;教員は授業の開始・終了の時刻を守ろうとしていた&#34;                          教員実施)
(反応 	&#34;教員は学生の反応を確かめながら授業を進めていた&#34;                          教員実施)
(熱意 	&#34;教員は熱意を持って授業をしていた&#34;                                        教員実施)
(理解 	&#34;私はこの授業内容を理解できた&#34;                                            総合評価)
(役立 	&#34;私はこの授業で学んだ内容はなんらかの形で将来的に役立つと感じた&#34;          総合評価)
(満足 	&#34;私は総合的に判断してこの授業で満足が得られた&#34;                            総合評価)))

(define responses &#39;((5 特に   &#34;特にそう思う&#34;       &#34;very much&#34;  &#34;I really think so&#34;)
		    (4 多少   &#34;多少そう思う&#34;	   &#34;fairly much&#34;  &#34;I somewhat think so&#34;)
		    (3 どちも &#34;どちらともいえない&#34; &#34;neither&#34;  &#34;I can&#39;t say either way&#34;)
		    (2 あまり &#34;あまりそう思わない&#34; &#34;not much&#34;  &#34;I do not think so much&#34;)
		    (1 全く   &#34;全くそう思わない&#34;   &#34;not at all&#34;  &#34;I do not think so at all&#34;)))
;; (sort responses #:key car &lt;)

(define bdy-rslt-img
  (lambda (imge-file)
    (element &#39;img class: &#34;result-image&#34; src: imge-file)))

(define Qsym-Bdys-rslt-imgs
;; Question symbol, list of body symbols
  (lambda (qsym bdys) ;; extensiong taking care of aith get-page-plots
    (map (lambda (bdy-rx) ; Racket style define vs. cute lambda?
	   (body-quest-plot-name bdy-rx qsym))
	 bdys)))

(define rslt-img-div
  (lambda (rslt-imgs)
    (element &#39;div class: &#34;result-images&#34;
	     (map bdy-rslt-img rslt-imgs))))

;; (output-xml (map bdy-rslt-img (Qsym-Bdys-rslt-imgs &#39;資料 bodies)))
;; &lt;img class=&#34;result-image&#34; src=&#34;20182H30K教員:資料20182.svg&#34; /&gt;&lt;img class=&#34;result-image&#34; src=&#34;20182H30K学科:資料20182.svg&#34; /&gt;&lt;img class=&#34;result-image&#34; src=&#34;20182H30K大学:資料20182.svg&#34; /&gt;

(define Qsym-&gt;Qli
  ;; Question-Symbol to Question item &lt;li&gt;Q&lt;/li&gt;
  (lambda (sym Qs)
    (element &#39;li class: &#34;ques-txt-ja&#34;
	     (als-ref sym Qs))))

(define Q-li-Rs-div
  ;; get Qli and image links ready for output-xml
  (lambda (sym ext) ;; To do, remove ext, not needed with new Qsym-Bdys-rslt-imgs def
    (list
     (Qsym-&gt;Qli sym questions)
     (rslt-img-div (Qsym-Bdys-rslt-imgs sym bodies)))))

(define Qs-w-Rs-&gt;ol
  ;; for output-xml get Qli and Rimages into ordered list
  (lambda (syms ext)
    (element &#39;ol class: &#34;questions-with-results&#34;
	     (map (lambda (sym) (Q-li-Rs-div sym ext)) syms))))

(define resp-levl-defn
  (lambda (rsp-row)
     (element &#39;li class: &#34;response-item&#34;
	      (string-join
	       (map -&gt;plot-label (list
				  (car rsp-row)
				  &#34;. &#34;
				  (caddr rsp-row)))
	       &#34;&#34;))))

(define resp-levl-list
  (lambda (defns)
    (element &#39;ol class: &#34;response-levels&#34;
	     (map resp-levl-defn (sort responses #:key car &lt;)))))

(define output-QsRs-page
  (lambda (als plt-ext)
    (let* ((yr-sr (string-join (map -&gt;plot-label (als-ref &#39;smr als)) &#34;&#34;))
	   ;;year semetsr
	   (pge-ttl (string-append &#34;FD アンケート結果 &#34; yr-sr)))
      (call-with-output-file (build-path working-directory
                                        (string-append &#34;FD-Anketo-Questions-Result-&#34; yr-sr &#34;.html&#34;)) #:exists &#39;truncate
			     (lambda (out)
			       (output-xml (xhtml
					    (head (title pge-ttl)
						  (meta http-equiv: &#34;Content-Type&#34; content: &#34;text/html;charset=utf-8&#34;)
                                                  (map style (list ;; saves ink/color to map style over a list of strings
                                                              &#34;@page { size: 210mm 297mm; margin: 4mm 4mm 6mm 4mm; }&#34;                       
                                                              &#34;h2 {margin-top: 10px; margin-bottom: 10px; font-size: 12pt;} &#34;
                                                              &#34;h3 {margin-top: 8px; margin-bottom: 8px; font-size: 10pt; }&#34;                 					    
                                                              &#34;ol.response-levels {margin-left: 0em; padding-left: 0; font-size: 11pt;&#34;
                                                              &#34;li.response-item {display: inline; margin-left: .5em; }&#34;       
                                                              &#34;li {page-break-inside: avoid; } &#34;                       
                                                              &#34;li.ques-txt-ja { margin-left: -.7em; font-size: 13pt; }&#34;
                                                              &#34;div.result-images {width: 100%;} &#34;                       
                                                              &#34;img.result-image { margin: 5px 0 10px 0 ; width:32%;  }&#34;)))
					    (body
					     (h2 pge-ttl)
					     (h3 &#34;回答数字の文&#34;)
					     (resp-levl-list responses)
					     (h3 &#34;設問の文と結果の図&#34;)
					     (Qs-w-Rs-&gt;ol quest-symbs plt-ext)
					     ;; (element &#39;ol class: &#34;questions&#34;
					     ;; 	   (map (lambda (sym) (Qsym-&gt;Qli sym questions)) quest-symbs))
					     ))
					   out))))))

(define generate-plot-images-and-html-page
  (lambda (list-of-alists plt-ext)
    (map (lambda (als)
	   (anket-reslt-alist-&gt;line-labl-chrts als quest-symbs))
	 list-of-alists)
    (output-QsRs-page (last list-of-alists) plt-ext)))

  (define write-plot-images-html-page-to
  (lambda (pth lst-of-alsts plt-ext)
      (generate-plot-images-and-html-page
       lst-of-alsts plt-ext)))

;; plot-type plot extension plt-ext
 (write-plot-images-html-page-to working-directory (list ind-als dep-als uni-als) (symbol-&gt;string page-plot-type))

;; End html page with .svg plots
;; Start png plots to png directory

(define plot-bod-als-to-percentlines-countlabels-to-bmps
  (lambda (BodAls  Qsyms #:kind (ext &#39;svg))
    ;; get orginal result data into associative list: QR-als
    (let ((QR-als (dta-&gt;Qss-Als Qsyms BodAls))
          (smr (string-join (map -&gt;plot-label (als-ref &#39;smr BodAls)) &#34;&#34;))
           (bod (-&gt;plot-label (car (als-ref &#39;nme BodAls)))))
      (define lines-percents-titled
	(lambda (QR)
	  (let* ((ttl (string-append smr &#34;  &#34; bod &#34;:&#34; (-&gt;plot-label (car QR))))
		 (plt-ttl (string-append ttl &#34;  &#34;
                                        (string-join (map -&gt;plot-label
                                                         (als-ref &#39;cls BodAls)) &#34;T/&#34;)
                                        &#34;S   Avg: &#34;
                                        (-&gt;plot-label
                                         (round (/ (cadr (als-ref &#39;cls BodAls))
                                                  (car (als-ref &#39;cls BodAls)))))
                                        &#34;S&#34;))
                 (fle-name (build-path working-directory shre-bmps-strn ; remove space from ttle for filename
                                      (string-append  (regexp-replace* &#34;  | &#34; ttl &#34;&#34;)
                                                    (-&gt;plot-label (car (als-ref &#39;smr BodAls)))
                                                    (-&gt;plot-label (cadr (als-ref &#39;smr BodAls)))
                                                    &#34;.&#34;
                                                    (symbol-&gt;string ext))))) ;; use page-plot-type later
            (plot (list (hrule 0 #:color 0) ;; need this for stck-ngtv-rslts
			(lines-percents-labels-counts (cadr QR))
			(stck-rslts (cadr QR))
			(stck-rslts (reverse (cadr QR)) #:algn &#39;top #:clr 0 #:sign -))
		#:x-min .5  #:x-max 5.9
		#:y-min -30 #:y-max 115
		#:width 400 #:height 250
		#:x-label &#34;levels&#34; #:y-label &#34;percent&#34;
		#:title plt-ttl
		#:out-file fle-name
 		#:out-kind ext))))
      (map lines-percents-titled QR-als))))

(define anket-reslt-alist-&gt;line-labl-chrts-w-ext
  (lambda (als Qsymbs #:ext (ext &#39;png))
    (parameterize ((plot-tick-size 3)
		   (plot-x-far-axis? #f)
		   (plot-y-far-axis? #f))
      (plot-bod-als-to-percentlines-countlabels-to-bmps als Qsymbs #:kind ext))))

(define write-ind-dep-uni-result-plots
  (lambda (ext-dir-sym)
      (map (lambda (als)
	     (anket-reslt-alist-&gt;line-labl-chrts-w-ext als quest-symbs #:ext ext-dir-sym))
	   (list ind-als dep-als uni-als))
    ))
      ;;(change-directory-to wrk-dir))))

(write-ind-dep-uni-result-plots shre-bmps-type)
</code></pre>
<ul><li>previous attempt: the basis of this script
<ul><li><a href="https://write.as/bs2facdev/racket-plot-stacked-lines-labeled-positive-and-negative">https://write.as/bs2facdev/racket-plot-stacked-lines-labeled-positive-and-negative</a>
<a href="https://write.as/bs2facdev/tag:Scheme" class="hashtag"><span>#</span><span class="p-category">Scheme</span></a> <a href="https://write.as/bs2facdev/tag:Racket" class="hashtag"><span>#</span><span class="p-category">Racket</span></a> <a href="https://write.as/bs2facdev/tag:FS4FT" class="hashtag"><span>#</span><span class="p-category">FS4FT</span></a> <a href="https://write.as/bs2facdev/tag:FS4FD" class="hashtag"><span>#</span><span class="p-category">FS4FD</span></a> <a href="https://write.as/bs2facdev/tag:facdev" class="hashtag"><span>#</span><span class="p-category">facdev</span></a> <a href="https://write.as/bs2facdev/tag:FacultyDevelopment" class="hashtag"><span>#</span><span class="p-category">FacultyDevelopment</span></a> <a href="https://write.as/bs2facdev/tag:DataVisualizatoin" class="hashtag"><span>#</span><span class="p-category">DataVisualizatoin</span></a> <a href="https://write.as/bs2facdev/tag:%E3%82%A2%E3%83%B3%E3%82%B1%E3%83%BC%E3%83%88" class="hashtag"><span>#</span><span class="p-category">アンケート</span></a> <a href="https://write.as/bs2facdev/tag:%E3%83%87%E3%83%BC%E3%82%BF%E8%A6%96%E8%A6%9A%E5%8C%96" class="hashtag"><span>#</span><span class="p-category">データ視覚化</span></a> <a href="https://write.as/bs2facdev/tag:graph" class="hashtag"><span>#</span><span class="p-category">graph</span></a> <a href="https://write.as/bs2facdev/tag:plot" class="hashtag"><span>#</span><span class="p-category">plot</span></a> <a href="https://write.as/bs2facdev/tag:DataVisualization" class="hashtag"><span>#</span><span class="p-category">DataVisualization</span></a></li></ul></li></ul>
]]></content:encoded>
      <guid>https://write.as/bs2facdev/racket-plot-faceted-view-of-questionnaire-data</guid>
      <pubDate>Mon, 08 Apr 2019 08:19:56 +0000</pubDate>
    </item>
    <item>
      <title>Racket Plot: Synoptic View for Questionnaires</title>
      <link>https://write.as/bs2facdev/racket-plot-synoptic-view-for-questionnaires?pk_campaign=rss-feed</link>
      <description>&lt;![CDATA[The code needs editing, but I like this view of questionnaire data where &#34;factor&#34; responses of 1 and 2 are negative, 3 is seemingly neutral, and 4 and 5 are positive. It seems possible to see things with this view that might not be possible with an average/mean of the responses.&#xA;&#xA;Synoptic View of Positive and Negative Responses for a Questionnaire&#xA;&#xA;The visualization needs to be on a page with the full text for the questions, the symbols for the numbered responses, the tables for the data, and an attempt to explain the visualization. &#xA;&#xA;Screenshot of the page output by the code below, includes the image above&#xA;!--more--&#xA;code&#xA;lang racket&#xA;&#xA;;; set the directory in which to write plot images and web page&#xA;(define working-directory&#xA;  (build-path (find-system-path &#39;home-dir)&#xA;&#x9;      &#34;FD&#34;&#xA;&#x9;      &#34;FD201802H30K-2C-SynopticPage&#34;))&#xA;&#xA;(unless (directory-exists? working-directory)&#xA;  (make-directory working-directory))&#xA;&#xA;(define img-ext-for-pge &#39;svg)&#xA;(define img-fle-for-pge (path-replace-extension&#xA;                         (build-path working-directory&#xA;                                    &#34;SynopticView&#34;)&#xA;                         (string-append &#34;.&#34; (symbol-  string img-ext-for-pge))))&#xA;&#xA;(require plot) ;; discrete-histogram, stacked-histogram etc&#xA;(require plot/utils) ;; -  plot-label&#xA;(require scribble/html/html) ;; for output-xml, html and class:&#xA;(require scribble/html) ;; for element&#xA;(require racket/require)&#xA;(require (only-in srfi/1 iota)) &#xA;&#xA;(define bodies &#39;(教員 学科 大学)) ;; Teacher, Department, University&#xA;&#xA;;; short keys and labels for questions and data&#xA;(define quest-symbs &#39;(出席 発言 取組 聞取 資料 時刻 反応 熱意 理解 役立 満足))&#xA;&#xA;;; データを入力し直すところ&#xA;(define ind-als ;;教員の連帯リスト associative list&#xA;  &#39;((nme (教員 TCR スモール 教養)) ;; NaME of BoDy bod 体&#xA;    (smr (2018 02 H30 K)) ;; 学期 SeMesteR&#xA;    (cls (1 68))         ;; 授業、教室 CLasS&#xA;    (dta ((33 28 6 1 0)   ;; データ、DaTA&#xA;&#x9; (8 27 19 9 5)&#xA;&#x9; (8 25 22 12 1)&#xA;&#x9; (37 25 6 0 0)&#xA;&#x9; (21 34 11 2 0)&#xA;&#x9; (49 16 3 0 0)&#xA;&#x9; (47 16 5 0 0)&#xA;&#x9; (56 11 1 0 0)&#xA;&#x9; (25 31 7 5 0)&#xA;&#x9; (17 33 15 2 1)&#xA;&#x9; (19 38 8 2 1)))))&#xA;&#xA;(define dep-als ;;学科 associative list&#xA;  &#39;((nme (学科 DPT 教養 大学))&#xA;    (smr (2018 02 H30 K))&#xA;    (cls (6 276))&#xA;    (dta ((198 59 16 3 0)&#xA;    (39 86 102 26 22)&#xA;    (50 96 90 29 9)&#xA;    (130 91 40 10 4)&#xA;    (98 107 55 12 3)&#xA;    (174 70 26 4 2)&#xA;    (125 95 48 5 3)&#xA;    (161 81 30 2 1)&#xA;    (99 114 45 13 5)&#xA;    (95 105 65 8 3)&#xA;    (89 120 51 9 7)))))&#xA;&#xA;(define uni-als ;;大学&#xA;  &#39;((nme (大学 UVY 南九州 学園))&#xA;    (smr (2018 02 H30 K))&#xA;    (cls (57 2403))&#xA;    (dta ((1679 479 202 31 10)&#xA;     (419 616 974 190 199)&#xA;     (684 822 692 134 65)&#xA;     (1341 670 293 69 28)&#xA;     (1200 695 374 86 42)&#xA;     (1702 480 169 28 17)&#xA;     (1315 652 349 52 33)&#xA;     (1537 585 236 21 19)&#xA;     (938 940 412 73 34)&#xA;     (1328 676 325 43 26)&#xA;     (1172 781 356 55 34)))))&#xA;&#xA;(define als-ref&#xA;  (lambda (idx als)&#xA;    (let ((tmp (assv idx als)))&#xA;      (if tmp (cadr tmp) #f))))&#xA;&#xA;(define counts-  percents&#xA;  (lambda (lon) ;; list of numbers&#xA;    (let ((total (apply + lon)))&#xA;    (map (lambda (count)&#xA;&#x9;     ( (/ count total) 100.0))&#xA;&#x9;   lon))))&#xA;&#xA;(define pnt-w-lbl&#xA;  (lambda (x n l (algn &#39;bottom) (sze 8) (pnt-clr 0) (lbel-angl 0))&#xA;    (point-label (vector x n) l #:anchor algn #:size sze #:point-color pnt-clr #:angle lbel-angl)))&#xA;&#xA;(define vline-y1-to-y2&#xA;  (lambda (x y1 y2 (clr 0)) ; y1 and y2 are percents&#xA;    (list&#xA;     (lines (map vector (list x x) (list 0 y1)) #:width 2 #:color clr)&#xA;     (lines (map vector (list x x) (list y1 y2)) #:width 4 #:color clr))))&#xA;&#xA;(define line-label ;; change name to line-label&#xA;  ;; xlevel percents, 4&#39;s count 5&#39;s count&#xA;  ;; defaults to positive line with anchor &#39;bottom&#xA;  ;;  over-ride anchor with &#39;top fo negative direction&#xA;  (lambda (x p4 p5 c4 c5 (lbl-aln &#39;bottom) (clr 0))&#xA;    ;; points always given with same sign +pos or -neg&#xA;    (let ((p4n5 (+ p4 p5))&#xA;&#xA;&#x9;  (cnt-lbl (string-join (map number-  string (list (abs c4) (abs c5))) &#34;:&#34;)))&#xA;      (list&#xA;       (pnt-w-lbl x p4n5 (-  plot-label cnt-lbl) lbl-aln)&#xA;       (vline-y1-to-y2 x p4 p4n5 clr))))) ;; 1 is #:color 1 (red)&#xA;&#xA;(define stck-rslts&#xA;  (lambda (row (x 5.5) (lbl-aln &#39;bottom)(clr 0) (sign +))&#xA;    (let ((cn5 (first row))&#xA;&#x9;   (cn4 (second row))&#xA;;;&#x9;   (x 5.5) ;; #:x-max will be 5.8&#xA;&#x9;   (pcnts (counts-  percents row))&#xA;&#x9;   (pr5 (first pcnts))&#xA;&#x9;   (pr4 (second pcnts)))&#xA;      (line-label x (sign pr4) (sign pr5) (sign cn4) (sign cn5) lbl-aln clr))))&#xA;&#xA;(define pos-neg-stacked-lines-labeled-row&#xA;  (lambda (row x)&#xA;    (list&#xA;     (stck-rslts row x &#39;bottom 1)&#xA;     (stck-rslts (reverse row) x &#39;top 0 -))))&#xA;(define pos-neg-stacked-lines-labeled-rows3&#xA;  (lambda (3rows x)&#xA;    (list &#xA;     (pos-neg-stacked-lines-labeled-row (car 3rows) (- x .30))&#xA;     (pos-neg-stacked-lines-labeled-row (cadr 3rows) x)&#xA;     (pos-neg-stacked-lines-labeled-row (caddr 3rows) (+ x .30)))))&#xA;&#xA;(define pos-neg-stacked-lines-labeled-rows3-quesN&#xA;  (lambda (d1 d2 d3) ;; data sets&#xA;    ;; number of rows = number of questions&#xA;    (let ((qn (length d1)))&#xA;      (define helper&#xA;&#x9;;; remainders&#xA;&#x9;(lambda (r1 r2 r3 n keep)&#xA;&#x9;  (cond&#xA;&#x9;   ((  n qn) (reverse (cons (hrule 0 #:color 0) keep)))&#xA;&#x9;   (else (helper (cdr r1) (cdr r2) (cdr r3) (+ 1 n)&#xA;&#x9;&#x9;&#x9; (cons keep&#xA;&#x9;&#x9;&#x9;       (cons&#xA;&#x9;&#x9;&#x9;&#x9;(pos-neg-stacked-lines-labeled-row (car r1) (- n .30))&#xA;&#x9;&#x9;&#x9;&#x9;(cons &#xA;&#x9;&#x9;&#x9;&#x9; (pos-neg-stacked-lines-labeled-row (car r2) n)&#xA;&#x9;&#x9;&#x9;&#x9; (pos-neg-stacked-lines-labeled-row (car r3) (+ n .30))))))))))&#xA;      (helper d1 d2 d3 1 &#39;()))))&#xA;&#xA;(define NQs (map list (range 1 12) quest-symbs))&#xA;&#xA;(define label-rows3&#xA;  (lambda (xmid yval labels)&#xA;    (list (point-label (vector (- xmid .30) yval) (car labels) #:anchor &#39;bottom #:point-size 0)&#xA;&#x9;  (point-label (vector xmid yval) (cadr labels) #:anchor &#39;bottom #:point-size 0)&#xA;&#x9;  (point-label (vector (+ xmid .30) yval) (caddr labels) #:anchor &#39;bottom #:point-size 0))))&#xA;&#xA;;; Synoptic View&#xA;(parameterize ((plot-x-ticks (linear-ticks #:number 11))       &#xA;&#x9;       (plot-y-ticks (linear-ticks #:number 8)) &#xA;&#x9;       (plot-x-far-axis? #f)                     &#xA;&#x9;       (plot-y-far-axis? #f))&#xA;  (plot (cons (label-rows3 1 100 (list &#34;教員&#34; &#34;学科&#34; &#34;大学&#34;))&#xA;&#x9;      (cons (label-rows3 5 100 (list &#34;教員&#34; &#34;学科&#34; &#34;大学&#34;))&#xA;&#x9;&#x9;    (cons (label-rows3 10 100 (list &#34;教員&#34; &#34;学科&#34; &#34;大学&#34;))&#xA;&#x9;&#x9;&#x9;  (cons (map (lambda (xval)&#xA;&#x9;&#x9;&#x9;&#x9;       (lines (list (vector xval 90) (vector xval 99)) #:color -2 #:style &#39;dot))&#xA;&#x9;&#x9;&#x9;&#x9;     (list .6 1.4 4.6 5.4 9.6 10.4))&#xA;&#x9;&#x9;&#x9;  (cons (map (lambda (nq) (point-label (vector (car nq) 105) (symbol-  string (cadr nq))&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&#x9;&#x9;       #:anchor &#39;bottom #:size 12&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&#x9;&#x9;       #:point-color -1 #:point-size 0))&#xA;&#x9;&#x9;&#x9;&#x9;     NQs)&#xA;&#x9;&#x9;&#x9;&#x9;(cons&#xA;&#x9;&#x9;&#x9;&#x9; (map (lambda (xval) &#xA;&#x9;&#x9;&#x9;&#x9;&#x9;(lines (list (vector xval -40) (vector xval 0)) #:color -2 #:style &#39;dot)) &#xA;&#x9;&#x9;&#x9;&#x9;      (iota 12 .5 1))&#xA;&#x9;&#x9;&#x9;&#x9; (cons&#xA;&#x9;&#x9;&#x9;&#x9;  (map (lambda (nq)&#xA;&#x9;&#x9;&#x9;&#x9;&#x9; (point-label (vector (car nq) -40)&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&#x9;      (symbol-  string(cadr nq))&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&#x9;      #:anchor &#39;bottom #:size 14&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&#x9;      #:point-color -1 #:point-size 0))&#xA;&#x9;&#x9;&#x9;&#x9;       NQs)&#xA;&#x9;&#x9;&#x9;&#x9;  (list&#xA;&#x9;&#x9;&#x9;&#x9;   (pos-neg-stacked-lines-labeled-rows3-quesN &#xA;&#x9;&#x9;&#x9;&#x9;    (als-ref &#39;dta ind-als) (als-ref &#39;dta dep-als) (als-ref &#39;dta uni-als))))))))))&#xA;&#xA;       #:x-label &#34;設問 questions&#34; #:y-label &#34;割合 percent&#34;&#xA;       #:x-min .3 #:x-max 11.7                &#xA;       #:y-min -40 #:y-max 110&#xA;       #:width 1500 #:height 700&#xA;       #:out-file img-fle-for-pge&#xA;       #:out-kind img-ext-for-pge))&#xA;&#xA;(define questions &#39;(&#xA;(出席 &#x9;&#34;私はこの授業によく出席した&#34;                                              学生取組)&#xA;(発言 &#x9;&#34;私は授業内容について質問や発言した&#34;                                      学生取組)&#xA;(取組 &#x9;&#34;私はこの科目に積極的に取り組んだ(予習と復習した)&#34;                      学生取組)&#xA;(聞取 &#x9;&#34;教員の声は聞き取りやすかった。&#34;                                          教員実施)&#xA;(資料 &#x9;&#34;教員の板書（またはPPT・配布資料など）は読みやすかった（見やすかった）&#34;   教員実施)&#xA;(時刻 &#x9;&#34;教員は授業の開始・終了の時刻を守ろうとしていた&#34;                          教員実施)&#xA;(反応 &#x9;&#34;教員は学生の反応を確かめながら授業を進めていた&#34;                          教員実施)&#xA;(熱意 &#x9;&#34;教員は熱意を持って授業をしていた&#34;                                        教員実施)&#xA;(理解 &#x9;&#34;私はこの授業内容を理解できた&#34;                                            総合評価)&#xA;(役立 &#x9;&#34;私はこの授業で学んだ内容はなんらかの形で将来的に役立つと感じた&#34;          総合評価)&#xA;(満足 &#x9;&#34;私は総合的に判断してこの授業で満足が得られた&#34;                            総合評価)))&#xA;&#xA;(define Q-li&#xA;  (lambda (qrow)&#xA;    (li class: &#34;question&#34; (string-append (symbol-  string (car qrow)) &#34; : &#34;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9; (cadr qrow)))))&#xA;(define Qs-ol&#xA;  (lambda (qs)&#xA;    (ol&#xA;     (map Q-li qs))))&#xA;&#xA;(define lst-  row&#xA;  (lambda (Qrslts)&#xA;    (tr&#xA;    (map td Qrslts))))&#xA;&#xA;(define th-row&#xA;  (lambda (rsp-txt-lst)&#xA;    (define helper&#xA;      (lambda (l n rsps keep)&#xA;&#x9;(cond&#xA;&#x9; ((  n l) (reverse keep))&#xA;&#x9; (else (helper l (+ 1 n) (cdr rsps)&#xA;&#x9;&#x9;       (cons&#xA;&#x9;&#x9;&#x9;(th&#xA;&#x9;&#x9;&#x9; (string-append (number-  string n) &#34;:&#34;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;(symbol-  string(cadar rsps))))&#xA;&#x9;&#x9;&#x9;keep))))))&#xA;    (helper (length rsp-txt-lst) 1 (reverse rsp-txt-lst) &#39;())))&#xA;&#xA;(define responses &#39;((5 特に   &#34;特にそう思う&#34;       &#34;very much&#34;  &#34;I really think so&#34;)&#xA;&#x9;&#x9;    (4 多少   &#34;多少そう思う&#34;&#x9;   &#34;fairly much&#34;  &#34;I somewhat think so&#34;)&#xA;&#x9;&#x9;    (3 どちも &#34;どちらともいえない&#34; &#34;neither&#34;  &#34;I can&#39;t say either way&#34;)&#xA;&#x9;&#x9;    (2 あまり &#34;あまりそう思わない&#34; &#34;not much&#34;  &#34;I do not think so much&#34;)&#xA;&#x9;&#x9;    (1 全く   &#34;全くそう思わない&#34;   &#34;not at all&#34;  &#34;I do not think so at all&#34;)))&#xA;&#xA;(define lsts-  table&#xA;  (lambda (als)&#xA;    (table class: &#34;results&#34;&#xA;          (caption (symbol-  string (car (als-ref &#39;nme als))))&#xA;          (th-row responses)&#xA;  ;;        (map th (iota 5 1 1))&#xA;          (map lst-  row (map reverse (als-ref &#39;dta als))))))&#xA;&#xA;(define R-li&#xA;  (lambda (rrow) ;; results list for one question, a row&#xA;    (li (string-append (symbol-  string (cadr rrow)) &#34; : &#34; (caddr rrow)))))&#xA;&#xA;(define Rs-ol&#xA;  (lambda (rs) ;; results for a body: TCR, DPT, UVY&#xA;    (ol&#xA;     (map R-li (reverse rs)))))&#xA;&#xA;(define output-synoptic-view-page&#xA;  (lambda (als)&#xA;    (let* ((year-strn (string-join (map -  plot-label (als-ref &#39;smr als)) &#34;&#34;))&#xA;&#x9;   (pge-ttl (string-append &#34;FD アンケート結果 Synoptic View 共観 &#34; year-strn)))&#xA;      (call-with-output-file&#xA;&#x9;  (build-path working-directory&#xA;&#x9;&#x9;      (string-append &#34;FD-Questionnaire-Results-Synoptic-View&#34; year-strn &#34;.html&#34;))&#xA;        #:exists &#39;truncate&#xA;&#x9;(lambda (out)&#xA;&#x9;  (output-xml (xhtml&#xA;&#x9;&#x9;       (head (title pge-ttl)&#xA;&#x9;&#x9;&#x9;     (meta http-equiv: &#34;Content-Type&#34; content: &#34;text/html;charset=utf-8&#34;)&#xA;&#x9;&#x9;&#x9;     (map style (list ;; saves ink/color to map style over a list of strings&#xA;&#x9;&#x9;&#x9;&#x9;&#x9; &#34;@page { size: 210mm 297mm; margin: 4mm 4mm 6mm 4mm; }&#34; &#xA;&#x9;&#x9;&#x9;&#x9;&#x9; &#34;h2 {margin-top: 10px; margin-bottom: 10px; font-size: 14pt;} &#34;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9; &#34;h3 {margin-top: 8px; margin-bottom: 8px; }&#34;&#xA;                                         &#34;div.questions-list { float: left; }&#34;&#xA;                                         &#34;div.results-explanation {float:left;}&#34;&#xA;                                         &#34;h3.image-explanation {  margin-top: 5em; }&#34;&#xA;                                         &#34;p.image-explanation { width: 20em; }&#34;&#xA;                                         &#34;div.results-tables { margin-left: 1em; }&#34;&#xA;                                         &#34;table.results { float: left; margin-left: 1em; }&#34;&#xA;                                         &#34;table.restuls th { text-align: right; }&#34;&#xA;                                         &#34;table.results td { text-align: right; width: 4em; }&#34;&#xA;                                         &#34;div.wide-view { clear: left; }&#34;)))&#xA;                       (body (h2 pge-ttl)&#xA;&#x9;&#x9;&#x9;(div  class: &#34;text-section questions-list&#34;&#xA;                             (h3 class: &#34;questions&#34; &#34;設問の文&#34;)&#xA;                             (Qs-ol questions))&#xA;                        (div class: &#34;text-section results-explanation&#34;&#xA;                            (h3 class: &#34;results explanation&#34; &#34;結果の文&#34;)&#xA;                            (Rs-ol responses)&#xA;                            (h3 class: &#34;text-section image-explanation&#34; &#34;図の説明&#34;)&#xA;                            (p class: &#34;image-explanation&#34;&#xA;                              &#34;肯定的回答の4と5は正号の赤線、5は太い。&#34; (br)&#xA;                              &#34;否形的回答の1と2は負号の黒線、1は太い。&#34;))&#xA;&#x9;&#x9;&#x9;(div  class: &#34;text-section results-tables&#34;&#xA;                             (h3 class: &#34;results&#34;  &#34;結果の表&#34; )&#xA;                             (lsts-  table  ind-als)&#xA;                             (lsts-  table  dep-als)&#xA;                             (lsts-  table  uni-als))&#xA;&#x9;&#x9;&#x9;(div  class: &#34;image-section wide-view&#34;&#xA;&#x9;&#x9;&#x9;&#x9; (h3 class: &#34;image&#34;  &#34;結果の図&#34;)&#xA;&#x9;&#x9;&#x9;&#x9; (element &#39;img src: img-fle-for-pge))))&#xA;                     out))))))&#xA;&#xA;(output-synoptic-view-page uni-als)&#xA;&#xA;The above was pasted from this session with DrRacket:&#xA;&#xA;This post&#39;s code working in DrRacket&#xA;&#xA;I should learn to use git, or even just really make use of the RCS conversioning I do in Emacs as a safety measure, just in case. But as I&#39;m learning, moving the minimum amount of code from Emacs into DrRacket lets me review while catching mistakes. I&#39;m hoping the DrRacket, with build-path will make the code work on proprietary operating systems. If some peers get interested enough to play with the scripts and views, it might be a step toward Free Software and developing abilities beyond Office Software.&#xA;&#xA;Screenshot of Emacs .rkt script and REPL  Geiser buffers&#xA;&#xA; #Scheme #Racket #FS4FT #FS4FD #facdev #FacultyDevelopment #DataVisualizatoin #アンケート #データ視覚化 #graph #plot #Questionnaires #アンケート]]&gt;</description>
      <content:encoded><![CDATA[<p>The code needs editing, but I like this view of questionnaire data where “factor” responses of 1 and 2 are negative, 3 is seemingly neutral, and 4 and 5 are positive. It seems possible to see things with this view that might not be possible with an average/mean of the responses.</p>

<p><img src="https://i.snap.as/L3L1teR.png" alt="Synoptic View of Positive and Negative Responses for a Questionnaire" title="Synoptic View of Positive and Negative Responses for a Questionnaire"/></p>

<p>The visualization needs to be on a page with the full text for the questions, the symbols for the numbered responses, the tables for the data, and an attempt to explain the visualization.</p>

<p><img src="https://i.snap.as/dnGJPFF.png" alt="Screenshot of the page output by the code below, includes the image above" title="Screenshot of the page output by the code below, includes the image above"/>
</p>

<h3 id="code">code</h3>

<pre><code>#lang racket

;; set the directory in which to write plot images and web page
(define working-directory
  (build-path (find-system-path &#39;home-dir)
	      &#34;FD&#34;
	      &#34;FD201802H30K-2C-SynopticPage&#34;))

(unless (directory-exists? working-directory)
  (make-directory working-directory))

(define img-ext-for-pge &#39;svg)
(define img-fle-for-pge (path-replace-extension
                         (build-path working-directory
                                    &#34;SynopticView&#34;)
                         (string-append &#34;.&#34; (symbol-&gt;string img-ext-for-pge))))

(require plot) ;; discrete-histogram, stacked-histogram etc
(require plot/utils) ;; -&gt;plot-label
(require scribble/html/html) ;; for output-xml, html and class:
(require scribble/html) ;; for element
(require racket/require)
(require (only-in srfi/1 iota)) 


(define bodies &#39;(教員 学科 大学)) ;; Teacher, Department, University

;; short keys and labels for questions and data
(define quest-symbs &#39;(出席 発言 取組 聞取 資料 時刻 反応 熱意 理解 役立 満足))

;; データを入力し直すところ
(define ind-als ;;教員の連帯リスト associative list
  &#39;((nme (教員 TCR スモール 教養)) ;; NaME of BoDy bod 体
    (smr (2018 02 H30 K)) ;; 学期 SeMesteR
    (cls (1 68))         ;; 授業、教室 CLasS
    (dta ((33 28 6 1 0)   ;; データ、DaTA
	 (8 27 19 9 5)
	 (8 25 22 12 1)
	 (37 25 6 0 0)
	 (21 34 11 2 0)
	 (49 16 3 0 0)
	 (47 16 5 0 0)
	 (56 11 1 0 0)
	 (25 31 7 5 0)
	 (17 33 15 2 1)
	 (19 38 8 2 1)))))

(define dep-als ;;学科 associative list
  &#39;((nme (学科 DPT 教養 大学))
    (smr (2018 02 H30 K))
    (cls (6 276))
    (dta ((198 59 16 3 0)
    (39 86 102 26 22)
    (50 96 90 29 9)
    (130 91 40 10 4)
    (98 107 55 12 3)
    (174 70 26 4 2)
    (125 95 48 5 3)
    (161 81 30 2 1)
    (99 114 45 13 5)
    (95 105 65 8 3)
    (89 120 51 9 7)))))

(define uni-als ;;大学
  &#39;((nme (大学 UVY 南九州 学園))
    (smr (2018 02 H30 K))
    (cls (57 2403))
    (dta ((1679 479 202 31 10)
     (419 616 974 190 199)
     (684 822 692 134 65)
     (1341 670 293 69 28)
     (1200 695 374 86 42)
     (1702 480 169 28 17)
     (1315 652 349 52 33)
     (1537 585 236 21 19)
     (938 940 412 73 34)
     (1328 676 325 43 26)
     (1172 781 356 55 34)))))


(define als-ref
  (lambda (idx als)
    (let ((tmp (assv idx als)))
      (if tmp (cadr tmp) #f))))

(define counts-&gt;percents
  (lambda (lon) ;; list of numbers
    (let ((total (apply + lon)))
    (map (lambda (count)
	     (* (/ count total) 100.0))
	   lon))))


(define pnt-w-lbl
  (lambda (x n l (algn &#39;bottom) (sze 8) (pnt-clr 0) (lbel-angl 0))
    (point-label (vector x n) l #:anchor algn #:size sze #:point-color pnt-clr #:angle lbel-angl)))

(define vline-y1-to-y2
  (lambda (x y1 y2 (clr 0)) ; y1 and y2 are percents
    (list
     (lines (map vector (list x x) (list 0 y1)) #:width 2 #:color clr)
     (lines (map vector (list x x) (list y1 y2)) #:width 4 #:color clr))))


(define line-label ;; change name to line-label
  ;; xlevel percents, 4&#39;s count 5&#39;s count
  ;; defaults to positive line with anchor &#39;bottom
  ;;  over-ride anchor with &#39;top fo negative direction
  (lambda (x p4 p5 c4 c5 (lbl-aln &#39;bottom) (clr 0))
    ;; points always given with same sign +pos or -neg
    (let ((p4n5 (+ p4 p5))

	  (cnt-lbl (string-join (map number-&gt;string (list (abs c4) (abs c5))) &#34;:&#34;)))
      (list
       (pnt-w-lbl x p4n5 (-&gt;plot-label cnt-lbl) lbl-aln)
       (vline-y1-to-y2 x p4 p4n5 clr))))) ;; 1 is #:color 1 (red)


(define stck-rslts
  (lambda (row (x 5.5) (lbl-aln &#39;bottom)(clr 0) (sign +))
    (let* ((cn5 (first row))
	   (cn4 (second row))
;;	   (x 5.5) ;; #:x-max will be 5.8
	   (pcnts (counts-&gt;percents row))
	   (pr5 (first pcnts))
	   (pr4 (second pcnts)))
      (line-label x (sign pr4) (sign pr5) (sign cn4) (sign cn5) lbl-aln clr))))

(define pos-neg-stacked-lines-labeled-row
  (lambda (row x)
    (list
     (stck-rslts row x &#39;bottom 1)
     (stck-rslts (reverse row) x &#39;top 0 -))))
(define pos-neg-stacked-lines-labeled-rows3
  (lambda (3rows x)
    (list 
     (pos-neg-stacked-lines-labeled-row (car 3rows) (- x .30))
     (pos-neg-stacked-lines-labeled-row (cadr 3rows) x)
     (pos-neg-stacked-lines-labeled-row (caddr 3rows) (+ x .30)))))


(define pos-neg-stacked-lines-labeled-rows3-quesN
  (lambda (d1 d2 d3) ;; data sets
    ;; number of rows = number of questions
    (let ((qn (length d1)))
      (define helper
	;; remainders
	(lambda (r1 r2 r3 n keep)
	  (cond
	   ((&gt; n qn) (reverse (cons (hrule 0 #:color 0) keep)))
	   (else (helper (cdr r1) (cdr r2) (cdr r3) (+ 1 n)
			 (cons keep
			       (cons
				(pos-neg-stacked-lines-labeled-row (car r1) (- n .30))
				(cons 
				 (pos-neg-stacked-lines-labeled-row (car r2) n)
				 (pos-neg-stacked-lines-labeled-row (car r3) (+ n .30))))))))))
      (helper d1 d2 d3 1 &#39;()))))

(define NQs (map list (range 1 12) quest-symbs))

(define label-rows3
  (lambda (xmid yval labels)
    (list (point-label (vector (- xmid .30) yval) (car labels) #:anchor &#39;bottom #:point-size 0)
	  (point-label (vector xmid yval) (cadr labels) #:anchor &#39;bottom #:point-size 0)
	  (point-label (vector (+ xmid .30) yval) (caddr labels) #:anchor &#39;bottom #:point-size 0))))


;; Synoptic View
(parameterize ((plot-x-ticks (linear-ticks #:number 11))       
	       (plot-y-ticks (linear-ticks #:number 8)) 
	       (plot-x-far-axis? #f)                     
	       (plot-y-far-axis? #f))
  (plot (cons (label-rows3 1 100 (list &#34;教員&#34; &#34;学科&#34; &#34;大学&#34;))
	      (cons (label-rows3 5 100 (list &#34;教員&#34; &#34;学科&#34; &#34;大学&#34;))
		    (cons (label-rows3 10 100 (list &#34;教員&#34; &#34;学科&#34; &#34;大学&#34;))
			  (cons (map (lambda (xval)
				       (lines (list (vector xval 90) (vector xval 99)) #:color -2 #:style &#39;dot))
				     (list .6 1.4 4.6 5.4 9.6 10.4))
			  (cons (map (lambda (nq) (point-label (vector (car nq) 105) (symbol-&gt;string (cadr nq))
							       #:anchor &#39;bottom #:size 12
							       #:point-color -1 #:point-size 0))
				     NQs)
				(cons
				 (map (lambda (xval) 
					(lines (list (vector xval -40) (vector xval 0)) #:color -2 #:style &#39;dot)) 
				      (iota 12 .5 1))
				 (cons
				  (map (lambda (nq)
					 (point-label (vector (car nq) -40)
						      (symbol-&gt;string(cadr nq))
						      #:anchor &#39;bottom #:size 14
						      #:point-color -1 #:point-size 0))
				       NQs)
				  (list
				   (pos-neg-stacked-lines-labeled-rows3-quesN 
				    (als-ref &#39;dta ind-als) (als-ref &#39;dta dep-als) (als-ref &#39;dta uni-als))))))))))

       #:x-label &#34;設問 questions&#34; #:y-label &#34;割合 percent&#34;
       #:x-min .3 #:x-max 11.7                
       #:y-min -40 #:y-max 110
       #:width 1500 #:height 700
       #:out-file img-fle-for-pge
       #:out-kind img-ext-for-pge))

(define questions &#39;(
(出席 	&#34;私はこの授業によく出席した&#34;                                              学生取組)
(発言 	&#34;私は授業内容について質問や発言した&#34;                                      学生取組)
(取組 	&#34;私はこの科目に積極的に取り組んだ(予習と復習した)&#34;                      学生取組)
(聞取 	&#34;教員の声は聞き取りやすかった。&#34;                                          教員実施)
(資料 	&#34;教員の板書（またはPPT・配布資料など）は読みやすかった（見やすかった）&#34;   教員実施)
(時刻 	&#34;教員は授業の開始・終了の時刻を守ろうとしていた&#34;                          教員実施)
(反応 	&#34;教員は学生の反応を確かめながら授業を進めていた&#34;                          教員実施)
(熱意 	&#34;教員は熱意を持って授業をしていた&#34;                                        教員実施)
(理解 	&#34;私はこの授業内容を理解できた&#34;                                            総合評価)
(役立 	&#34;私はこの授業で学んだ内容はなんらかの形で将来的に役立つと感じた&#34;          総合評価)
(満足 	&#34;私は総合的に判断してこの授業で満足が得られた&#34;                            総合評価)))

(define Q-li
  (lambda (qrow)
    (li class: &#34;question&#34; (string-append (symbol-&gt;string (car qrow)) &#34; : &#34;
					 (cadr qrow)))))
(define Qs-ol
  (lambda (qs)
    (ol
     (map Q-li qs))))

(define lst-&gt;row
  (lambda (Qrslts)
    (tr
    (map td Qrslts))))

(define th-row
  (lambda (rsp-txt-lst)
    (define helper
      (lambda (l n rsps keep)
	(cond
	 ((&gt; n l) (reverse keep))
	 (else (helper l (+ 1 n) (cdr rsps)
		       (cons
			(th
			 (string-append (number-&gt;string n) &#34;:&#34;
					(symbol-&gt;string(cadar rsps))))
			keep))))))
    (helper (length rsp-txt-lst) 1 (reverse rsp-txt-lst) &#39;())))


(define responses &#39;((5 特に   &#34;特にそう思う&#34;       &#34;very much&#34;  &#34;I really think so&#34;)
		    (4 多少   &#34;多少そう思う&#34;	   &#34;fairly much&#34;  &#34;I somewhat think so&#34;)
		    (3 どちも &#34;どちらともいえない&#34; &#34;neither&#34;  &#34;I can&#39;t say either way&#34;)
		    (2 あまり &#34;あまりそう思わない&#34; &#34;not much&#34;  &#34;I do not think so much&#34;)
		    (1 全く   &#34;全くそう思わない&#34;   &#34;not at all&#34;  &#34;I do not think so at all&#34;)))

(define lsts-&gt;table
  (lambda (als)
    (table class: &#34;results&#34;
          (caption (symbol-&gt;string (car (als-ref &#39;nme als))))
          (th-row responses)
  ;;        (map th (iota 5 1 1))
          (map lst-&gt;row (map reverse (als-ref &#39;dta als))))))




(define R-li
  (lambda (rrow) ;; results list for one question, a row
    (li (string-append (symbol-&gt;string (cadr rrow)) &#34; : &#34; (caddr rrow)))))

(define Rs-ol
  (lambda (rs) ;; results for a body: TCR, DPT, UVY
    (ol
     (map R-li (reverse rs)))))

(define output-synoptic-view-page
  (lambda (als)
    (let* ((year-strn (string-join (map -&gt;plot-label (als-ref &#39;smr als)) &#34;&#34;))
	   (pge-ttl (string-append &#34;FD アンケート結果 Synoptic View 共観 &#34; year-strn)))
      (call-with-output-file
	  (build-path working-directory
		      (string-append &#34;FD-Questionnaire-Results-Synoptic-View&#34; year-strn &#34;.html&#34;))
        #:exists &#39;truncate
	(lambda (out)
	  (output-xml (xhtml
		       (head (title pge-ttl)
			     (meta http-equiv: &#34;Content-Type&#34; content: &#34;text/html;charset=utf-8&#34;)
			     (map style (list ;; saves ink/color to map style over a list of strings
					 &#34;@page { size: 210mm 297mm; margin: 4mm 4mm 6mm 4mm; }&#34; 
					 &#34;h2 {margin-top: 10px; margin-bottom: 10px; font-size: 14pt;} &#34;
					 &#34;h3 {margin-top: 8px; margin-bottom: 8px; }&#34;
                                         &#34;div.questions-list { float: left; }&#34;
                                         &#34;div.results-explanation {float:left;}&#34;
                                         &#34;h3.image-explanation {  margin-top: 5em; }&#34;
                                         &#34;p.image-explanation { width: 20em; }&#34;
                                         &#34;div.results-tables { margin-left: 1em; }&#34;
                                         &#34;table.results { float: left; margin-left: 1em; }&#34;
                                         &#34;table.restuls th { text-align: right; }&#34;
                                         &#34;table.results td { text-align: right; width: 4em; }&#34;
                                         &#34;div.wide-view { clear: left; }&#34;)))
                       (body (h2 pge-ttl)
			(div  class: &#34;text-section questions-list&#34;
                             (h3 class: &#34;questions&#34; &#34;設問の文&#34;)
                             (Qs-ol questions))
                        (div class: &#34;text-section results-explanation&#34;
                            (h3 class: &#34;results explanation&#34; &#34;結果の文&#34;)
                            (Rs-ol responses)
                            (h3 class: &#34;text-section image-explanation&#34; &#34;図の説明&#34;)
                            (p class: &#34;image-explanation&#34;
                              &#34;肯定的回答の4と5は正号の赤線、5は太い。&#34; (br)
                              &#34;否形的回答の1と2は負号の黒線、1は太い。&#34;))
			(div  class: &#34;text-section results-tables&#34;
                             (h3 class: &#34;results&#34;  &#34;結果の表&#34; )
                             (lsts-&gt;table  ind-als)
                             (lsts-&gt;table  dep-als)
                             (lsts-&gt;table  uni-als))
			(div  class: &#34;image-section wide-view&#34;
				 (h3 class: &#34;image&#34;  &#34;結果の図&#34;)
				 (element &#39;img src: img-fle-for-pge))))
                     out))))))

(output-synoptic-view-page uni-als)
</code></pre>

<p>The above was pasted from this session with DrRacket:</p>

<p><img src="https://i.snap.as/Mu6mR6N.png" alt="This post&#39;s code working in DrRacket" title="This post&#39;s code working in DrRacket"/></p>

<p>I should learn to use git, or even just really make use of the RCS conversioning I do in Emacs as a safety measure, just in case. But as I&#39;m learning, moving the minimum amount of code from Emacs into DrRacket lets me review while catching mistakes. I&#39;m hoping the DrRacket, with <code>build-path</code> will make the code work on proprietary operating systems. If some peers get interested enough to play with the scripts and views, it might be a step toward Free Software and developing abilities beyond Office Software.</p>

<p><img src="https://i.snap.as/BM9Y5oR.png" alt="Screenshot of Emacs .rkt script and REPL  Geiser buffers" title="Screenshot of Emacs .rkt script and REPL  Geiser buffers"/></p>

<p> <a href="https://write.as/bs2facdev/tag:Scheme" class="hashtag"><span>#</span><span class="p-category">Scheme</span></a> <a href="https://write.as/bs2facdev/tag:Racket" class="hashtag"><span>#</span><span class="p-category">Racket</span></a> <a href="https://write.as/bs2facdev/tag:FS4FT" class="hashtag"><span>#</span><span class="p-category">FS4FT</span></a> <a href="https://write.as/bs2facdev/tag:FS4FD" class="hashtag"><span>#</span><span class="p-category">FS4FD</span></a> <a href="https://write.as/bs2facdev/tag:facdev" class="hashtag"><span>#</span><span class="p-category">facdev</span></a> <a href="https://write.as/bs2facdev/tag:FacultyDevelopment" class="hashtag"><span>#</span><span class="p-category">FacultyDevelopment</span></a> <a href="https://write.as/bs2facdev/tag:DataVisualizatoin" class="hashtag"><span>#</span><span class="p-category">DataVisualizatoin</span></a> <a href="https://write.as/bs2facdev/tag:%E3%82%A2%E3%83%B3%E3%82%B1%E3%83%BC%E3%83%88" class="hashtag"><span>#</span><span class="p-category">アンケート</span></a> <a href="https://write.as/bs2facdev/tag:%E3%83%87%E3%83%BC%E3%82%BF%E8%A6%96%E8%A6%9A%E5%8C%96" class="hashtag"><span>#</span><span class="p-category">データ視覚化</span></a> <a href="https://write.as/bs2facdev/tag:graph" class="hashtag"><span>#</span><span class="p-category">graph</span></a> <a href="https://write.as/bs2facdev/tag:plot" class="hashtag"><span>#</span><span class="p-category">plot</span></a> <a href="https://write.as/bs2facdev/tag:Questionnaires" class="hashtag"><span>#</span><span class="p-category">Questionnaires</span></a> <a href="https://write.as/bs2facdev/tag:%E3%82%A2%E3%83%B3%E3%82%B1%E3%83%BC%E3%83%88" class="hashtag"><span>#</span><span class="p-category">アンケート</span></a></p>
]]></content:encoded>
      <guid>https://write.as/bs2facdev/racket-plot-synoptic-view-for-questionnaires</guid>
      <pubDate>Wed, 27 Mar 2019 13:31:43 +0000</pubDate>
    </item>
    <item>
      <title>Racket Plot: stacked lines labeled, positive and negative</title>
      <link>https://write.as/bs2facdev/racket-plot-stacked-lines-labeled-positive-and-negative?pk_campaign=rss-feed</link>
      <description>&lt;![CDATA[While using questionnaire data to learn plotting, questions come to mind. Averages don&#39;t make sense for &#34;ranked&#34; &#34;factors&#34;, for numbered responses to questions about how much a person agrees or disagrees with a question. Maybe seeing the percentage and number of positive responses versus negative responses will help in the search for meaning in the data. &#xA;&#xA;Top of Browser page showing first two question-result sections&#xA;&#xA;With Racket it is possible to transform and view the data however you like. It&#39;s nice to be able to implement a view out of curiosity. I&#39;m hoping the stacked lines with their labels provide enough hints for people to figure out that they are combinations of responses of 4 and 5 in a positive direction, and 1 and 2 in a negative direction.&#xA;&#xA;Negative responses were most frequent for the question about student speaking, questioning in class&#xA;&#xA; If there is time to go over the code again there must be less repetitive way to stack negative lines after stacking positive lines. Getting started on that gave me a change to use Racket&#39;s define to give the pnt-w-lbl procedure an optional argument. &#xA;&#xA;Years ago with gnuplot I  plotted &#34;enthused&#34;熱意 results against &#34;satisified&#34;満足 responses. Naomi Klein quoted a Harpers article by a professor that said he refused to be &#34;cool&#34; like a Marshall McLuhan screen. &#xA;&#xA;For now though, I just want to see how Racket can replace two pages oddly scaled visualizations and averages. It&#39;s time to move into other work, after adjusting the css styles so that the generated page fits onto two A4 papers. &#xA;&#xA;Here&#39;s proof that the code pasted in below worked in DrRacket:&#xA;&#xA;DrRacket Screenshot&#xA;&#xA;!--more--&#xA;code&#xA;lang racket&#xA;&#xA;;; set the directory in which to write plot images&#xA;(define working-directory&#xA;  (build-path (find-system-path &#39;home-dir)&#xA;&#x9;      &#34;FD201802H30K-2B&#34;))&#xA;&#xA;(unless (directory-exists? working-directory)&#xA;  (make-directory working-directory))&#xA;&#xA;;; choose image extension for htmlpage&#xA;;;  the #:out-kind for plot&#xA;(define page-plot-type &#39;svg)&#xA;&#xA;;; choose image extension for bitmaps&#xA;;;  #:out-kind for plot, and name of directory &#xA;;; for bitmaps, useful to share on-line&#xA;(define bitmap-plot-type &#39;png)&#xA;&#xA;(define make-or-clear-directory&#xA;  ;; can&#39;t use this with absolute directory&#xA;  (lambda (pth) ;; path, string, or list of strings ok!&#xA;    (let ((p (build-path working-directory pth))) &#xA;      (if (directory-exists? p)&#xA;         (delete-directory/files p)&#xA;         (make-directory p)))))&#xA;&#xA;(require plot) ;; discrete-histogram, stacked-histogram etc&#xA;(require plot/utils) ;; -  plot-label&#xA;(require scribble/html/html) ;; for output-xml, html and class:&#xA;(require scribble/html) ;; for element&#xA;&#xA;;; set the order of images in output page&#xA;(define bodies &#39;(教員 学科 大学)) ;; Teacher, Department, University&#xA;&#xA;;; short keys and labels for questions and data&#xA;(define quest-symbs &#39;(出席 発言 取組 聞取 資料 時刻 反応 熱意 理解 役立 満足))&#xA;&#xA;;; データを入力し直すところ&#xA;(define ind-als ;;教員の連帯リスト associative list&#xA;  &#39;((nme (教員 TCR スモール 教養)) ;; NaME of BoDy bod 体&#xA;    (smr (2018 02 H30 K)) ;; 学期 SeMesteR&#xA;    (cls (1 68))         ;; 授業、教室 CLasS&#xA;    (dta ((33 28 6 1 0)   ;; データ、DaTA&#xA;&#x9; (8 27 19 9 5)&#xA;&#x9; (8 25 22 12 1)&#xA;&#x9; (37 25 6 0 0)&#xA;&#x9; (21 34 11 2 0)&#xA;&#x9; (49 16 3 0 0)&#xA;&#x9; (47 16 5 0 0)&#xA;&#x9; (56 11 1 0 0)&#xA;&#x9; (25 31 7 5 0)&#xA;&#x9; (17 33 15 2 1)&#xA;&#x9; (19 38 8 2 1)))))&#xA;&#xA;(define dep-als ;;学科 associative list&#xA;  &#39;((nme (学科 DPT 教養 大学))&#xA;    (smr (2018 02 H30 K))&#xA;    (cls (6 276))&#xA;    (dta ((198 59 16 3 0)&#xA;    (39 86 102 26 22)&#xA;    (50 96 90 29 9)&#xA;    (130 91 40 10 4)&#xA;    (98 107 55 12 3)&#xA;    (174 70 26 4 2)&#xA;    (125 95 48 5 3)&#xA;    (161 81 30 2 1)&#xA;    (99 114 45 13 5)&#xA;    (95 105 65 8 3)&#xA;    (89 120 51 9 7)))))&#xA;&#xA;(define uni-als ;;大学&#xA;  &#39;((nme (大学 UVY 南九州 学園))&#xA;    (smr (2018 02 H30 K))&#xA;    (cls (57 2403))&#xA;    (dta ((1679 479 202 31 10)&#xA;     (419 616 974 190 199)&#xA;     (684 822 692 134 65)&#xA;     (1341 670 293 69 28)&#xA;     (1200 695 374 86 42)&#xA;     (1702 480 169 28 17)&#xA;     (1315 652 349 52 33)&#xA;     (1537 585 236 21 19)&#xA;     (938 940 412 73 34)&#xA;     (1328 676 325 43 26)&#xA;     (1172 781 356 55 34)))))&#xA;&#xA;;; copied from &#34;Racket for Data Science&#34; code&#xA;;;   by Nicholas M. Van Horn,  n3mo&#xA;;;    moved by his respect for Chicken Scheme&#xA;(define als-ref&#xA;  (lambda (idx als)&#xA;    (let ((tmp (assv idx als)))&#xA;      (if tmp (cadr tmp) #f))))&#xA;&#xA;(define counts-  percents&#xA;  (lambda (lon) ;; list of numbers&#xA;    (let ((total (apply + lon)))&#xA;    (map (lambda (count)&#xA;&#x9;     ( (/ count total) 100.0))&#xA;&#x9;   lon))))&#xA;&#xA;(define pnt-w-lbl&#xA;  (lambda (x n l (algn &#39;bottom))&#xA;    (point-label (vector x n) l #:anchor algn #:size 8)))&#xA;;; adjust font-size for big numbers here&#xA;;;  with too many digits #:angle 170 might help&#xA;&#xA;(define vline-to-y&#xA;  (lambda (x y)&#xA;    (lines (map vector (list x x) (list 0 y)))))&#xA;&#xA;(define vline-y1-to-y2&#xA;  (lambda (x y1 y2) ; y1 and y2 are percents&#xA;    (list&#xA;     (lines (map vector (list x x) (list 0 y1)) #:width 2)&#xA;     (lines (map vector (list x x) (list y1 y2)) #:width 3))))&#xA;&#xA;(define neg-vline-y1-to-y2&#xA;  (lambda (x y1 y2) ;; y1 and y2 are percents&#xA;    (list&#xA;     (lines (map vector (list x x) (list 0 (- y1))) #:color 0 #:width 3)&#xA;     (lines (map vector (list x x) (list (- y1 ) (- y2))) #:color -1 #:width 2))))&#xA;&#xA;;; 4count, 5count : 1count, 2count &#xA;(define pos-line-label&#xA;  ;; xlevel percents, 4&#39;s count 5&#39;s count&#xA;  (lambda (x p4 p5 c4 c5)&#xA;    (let ((p4n5 (+ p4 p5))&#xA;&#x9;  (cnt-lbl (string-join (map number-  string (list c4 c5)) &#34;:&#34;)))&#xA;      (list&#xA;       (pnt-w-lbl x p4n5 (-  plot-label cnt-lbl))&#xA;       (vline-y1-to-y2 x p4 p4n5)))))&#xA;&#xA;(define neg-line-label&#xA;  (lambda (x p1 p2 c1 c2)&#xA;    (let ((p1n2 (- (+ p1 p2)))&#xA;&#x9;  (cnt-lbl (string-join (map number-  string (list c1 c2)) &#34;:&#34;)))&#xA;      (list&#xA;       (pnt-w-lbl x p1n2 (-  plot-label cnt-lbl) &#39;top)&#xA;       (neg-vline-y1-to-y2 x p2 (+ p1 p2))))))&#xA;&#xA;(define stck-ngtv-rslts&#xA;  (lambda (row)&#xA;    (let ((cn1 (fifth row))&#xA;&#x9;   (cn2 (fourth row))&#xA;&#x9;   (x 5.5)&#xA;&#x9;   (pcnts (counts-  percents row))&#xA;&#x9;   (pr1 (fifth pcnts))&#xA;&#x9;   (pr2 (fourth pcnts)))&#xA;      (neg-line-label x pr1 pr2 cn1 cn2))))&#xA;&#xA;(define stck-pstv-rslts&#xA;  (lambda (row)&#xA;    (let ((cn5 (first row))&#xA;&#x9;   (cn4 (second row))&#xA;&#x9;   (x 5.5) ;; #:xmax will be 5.8&#xA;&#x9;   (pcnts (counts-  percents row))&#xA;&#x9;   (pr5 (first pcnts))&#xA;&#x9;   (pr4 (second pcnts)))&#xA;      (pos-line-label x pr4 pr5 cn4 cn5))))&#xA;&#x9;   &#xA;(define lines-percents-labels-counts&#xA;  ;; for each row of Question Results&#xA;  ;;  get vline-to-y and pnt-w-lbl ready for plot&#xA;  (lambda (lon)&#xA;    (let ((pcnts (counts-  percents lon))&#xA;&#x9;  (lvels &#39;(5 4 3 2 1))&#xA;&#x9;  (tot-lab (-  plot-label (apply + lon))))&#xA;      (append ;; need a flat list for plot&#xA;       (map (lambda (l p) ;; level percent&#xA;&#x9;      (vline-to-y l p))&#xA;&#x9;    lvels pcnts)&#xA;       (map (lambda (x n l)&#xA;&#x9;      ;; xResponse level nNumber point lLabel&#xA;&#x9;      (pnt-w-lbl x n l))&#xA;&#x9;    lvels pcnts&#xA;&#x9;    (map (lambda (s) (string-append s &#34;/&#34; tot-lab))&#xA;&#x9;&#x9; (map -  plot-label lon)))))))&#xA;&#xA;;; get data ready for lines-percents-labels-counts&#xA;(define dta-  Qss-Als&#xA;  (lambda (Qss Als) ;; Question Symbols, A-list&#xA;    (map list Qss (als-ref &#39;dta Als))))&#xA;&#xA;;; for pngs change &#34;.svg&#34; and &#39;svg to &#34;.png&#34; and &#39;png&#xA;;; below ~w-ext adds ext argument &#xA;(define plot-bod-als-to-percentlines-countlabels&#xA;  (lambda (BodAls  Qsyms)&#xA;    ;; get orginal result data into associative list: QR-als&#xA;    (let ((QR-als (dta-  Qss-Als Qsyms BodAls)) &#xA;&#x9;   (bod (-  plot-label (car (als-ref &#39;nme BodAls)))))&#xA;      (define lines-percents-titled&#xA;&#x9;(lambda (QR)&#xA;&#x9;  (let ((ttl (string-append bod &#34;:&#34; (-  plot-label (car QR))))&#xA;&#x9;&#x9; (plt-ttl (string-append ttl &#34;  &#34;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9; (string-join (map -  plot-label&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&#x9;&#x9;   (als-ref &#39;cls BodAls)) &#34;T/&#34;) &#34;S&#34;))&#xA;&#x9;&#x9; (fle-name (build-path working-directory (string-append ttl&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;  (-  plot-label (car (als-ref &#39;smr BodAls)))&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;  (-  plot-label (cadr (als-ref &#39;smr BodAls))) &#34;.svg&#34;))))&#xA;&#x9;    (plot (list (hrule 0 #:color 0) ;; need this for stck-ngtv-rslts&#xA;&#x9;&#x9;&#x9;(lines-percents-labels-counts (cadr QR))&#xA;&#x9;&#x9;&#x9;(stck-pstv-rslts (cadr QR))&#xA;&#x9;&#x9;&#x9;(stck-ngtv-rslts (cadr QR)))&#xA;&#x9;&#x9;#:x-min .5  #:x-max 5.9&#xA;&#x9;&#x9;#:y-min -30 #:y-max 115&#xA;&#x9;&#x9;#:width 400 #:height 250&#xA;&#x9;&#x9;#:x-label &#34;levels&#34; #:y-label &#34;percent&#34;&#xA;&#x9;&#x9;#:title plt-ttl&#xA;&#x9;&#x9;#:out-file fle-name&#xA; &#x9;&#x9;#:out-kind page-plot-type))))&#xA;      (map lines-percents-titled QR-als))))&#xA;&#xA;;; (define delete-dir-files&#xA;;;   (lambda (dir)&#xA;;;     (map delete-file&#xA;;; &#x9; (map (lambda (f) (build-path dir f))&#xA;;; &#x9;      (directory-list dir)))))&#xA;&#xA;;; need better names&#xA;(define anket-reslt-alist-  line-labl-chrts&#xA;  ;; call plot-bod-als-to with ink-minimizing parameters&#xA;  (lambda (als Qsymbs)&#xA;    (parameterize ((plot-tick-size 3)&#xA;&#x9;&#x9;   (plot-x-far-axis? #f)&#xA;&#x9;&#x9;   (plot-y-far-axis? #f))&#xA;      (plot-bod-als-to-percentlines-countlabels als Qsymbs))))&#xA;&#xA;;; End of plot output, image file generationg&#xA;;; Start of html page generation&#xA;;;    using scribble/html/html&#xA;&#xA;(define dir-lis-strs&#xA;  (lambda (dir)&#xA;    (let ((d (if (symbol? dir) (symbol-  string dir) dir)))&#xA;    (map path-  string (directory-list d)))))&#xA;&#xA;(define mtchd-files&#xA;  (lambda (rxp dir)&#xA;    (filter (lambda (s) (regexp-match rxp s))&#xA;&#x9;    (dir-lis-strs dir))))&#xA;;; (mtchd-files #rx&#34;学科&#34; &#39;csv)&#xA;      &#xA;(define bod-img&#xA;  ;; regexp body, reqexp questions&#xA;  (lambda (rxB rxQ)&#xA;    ;; no dir: &#34;.&#34;&#xA;    ;; keep everything in one, current directory for now&#xA;    (filter (lambda (s) (regexp-match rxB s))&#xA;&#x9;    ;; later: (current-directory-for-user) &#xA;&#x9;    (mtchd-files rxQ &#34;.&#34;))))  ;; working-directory&#xA;;; (bod-img #rx&#34;大学:.+svg$&#34; #rx&#34;理解&#34; &#34;.&#34;)&#xA;;; &#39;(&#34;大学:理解201801.png&#34;)&#xA;&#xA;;; quest-symbs as alst keys&#xA;(define questions &#39;(&#xA;(出席 &#x9;&#34;私はこの授業によく出席した&#34;                                              学生取組)&#xA;(発言 &#x9;&#34;私は授業内容について質問や発言した&#34;                                      学生取組)&#xA;(取組 &#x9;&#34;私はこの科目に積極的に取り組んだ(予習と復習した)&#34;                      学生取組)&#xA;(聞取 &#x9;&#34;教員の声は聞き取りやすかった。&#34;                                          教員実施)&#xA;(資料 &#x9;&#34;教員の板書(またはPPT・配布資料など)は読みやすかった(見やすかった)&#34;   教員実施)&#xA;(時刻 &#x9;&#34;教員は授業の開始・終了の時刻を守ろうとしていた&#34;                          教員実施)&#xA;(反応 &#x9;&#34;教員は学生の反応を確かめながら授業を進めていた&#34;                          教員実施)&#xA;(熱意 &#x9;&#34;教員は熱意を持って授業をしていた&#34;                                        教員実施)&#xA;(理解 &#x9;&#34;私はこの授業内容を理解できた&#34;                                            総合評価)&#xA;(役立 &#x9;&#34;私はこの授業で学んだ内容はなんらかの形で将来的に役立つと感じた&#34;          総合評価)&#xA;(満足 &#x9;&#34;私は総合的に判断してこの授業で満足が得られた&#34;                            総合評価)))&#xA;&#xA;(define responses &#39;((5 特に   &#34;特にそう思う&#34;       &#34;very much&#34;  &#34;I really think so&#34;)&#xA;&#x9;&#x9;    (4 多少   &#34;多少そう思う&#34;&#x9;   &#34;fairly much&#34;  &#34;I somewhat think so&#34;)&#xA;&#x9;&#x9;    (3 どちも &#34;どちらともいえない&#34; &#34;neither&#34;  &#34;I can&#39;t say either way&#34;)&#xA;&#x9;&#x9;    (2 あまり &#34;あまりそう思わない&#34; &#34;not much&#34;  &#34;I do not think so much&#34;)&#xA;&#x9;&#x9;    (1 全く   &#34;全くそう思わない&#34;   &#34;not at all&#34;  &#34;I do not think so at all&#34;)))&#xA;;; (sort responses #:key car &lt;)&#xA;&#xA;(define bdy-rslt-img&#xA;  (lambda (imge-file)&#xA;    (element &#39;img class: &#34;result-image&#34; src: imge-file)))&#xA;;; (output-xml (bdy-rslt-img (bod-img #rx&#34;大学:.+svg$&#34; #rx&#34;理解&#34; &#34;.&#34;)))&#xA;;; img class=&#34;result-image&#34; src=&#34;大学:理解201801.png&#34; /&#xA;&#xA;;; get list of result images in bodies order for rslt-img-div&#xA;&#xA;;; regexp&lt;-symbol: rx from sym&#xA;(define symbol-  regexp&#xA;  (lambda (sym)&#xA;    (regexp (symbol-  string sym))))&#xA;&#xA;(define make-regexp-w-ext&#xA;  (lambda (sym ext-sym)&#xA;    (regexp (string-append&#xA;             (symbol-  string sym) &#34;:&#34;&#xA;             &#34;.+&#34;&#xA;             (symbol-  string ext-sym) &#34;$&#34;))))&#xA;&#xA;(define Qsym-Bdys-rslt-imgs&#xA;;; Question symbol, list of body symbols&#xA;  (lambda (qsym bdys ext)&#xA;    (map (lambda (bdy-rx)&#xA;&#x9;   (bod-img bdy-rx (symbol-  regexp qsym)))&#xA;&#x9; (map (lambda (bod) (make-regexp-w-ext bod ext))  bdys))))&#xA;&#xA;(define rslt-img-div&#xA;  (lambda (rslt-imgs)&#xA;    (element &#39;div class: &#34;result-images&#34;&#xA;&#x9;     (map bdy-rslt-img rslt-imgs))))&#xA;;; (output-xml (rslt-img-div (Qsym-Bdys-rslt-imgs &#39;理解 bodies)))&#xA;;; div class=&#34;result-images&#34;img class=&#34;result-image&#34; src=&#34;教員:理解201801.png&#34; /img class=&#34;result-image&#34; src=&#34;学科:理解201801.png&#34; /img class=&#34;result-image&#34; src=&#34;大学:理解201801.png&#34; //div&#xA;&#xA;(define Qsym-  Qli&#xA;  ;; Question-Symbol to Question item liQ/li&#xA;  (lambda (sym Qs)&#xA;    (element &#39;li class: &#34;ques-txt-ja&#34;&#xA;&#x9;     (als-ref sym Qs))))&#xA;&#xA;(define Q-li-Rs-div&#xA;  ;; get Qli and image links ready for output-xml&#xA;  (lambda (sym ext)&#xA;    (list&#xA;     (Qsym-  Qli sym questions)&#xA;     (rslt-img-div (Qsym-Bdys-rslt-imgs sym bodies ext)))))&#xA;&#xA;(define Qs-w-Rs-  ol&#xA;  ;; for output-xml get Qli and Rimages into ordered list&#xA;  (lambda (syms ext)&#xA;    (element &#39;ol class: &#34;questions-with-results&#34;&#xA;&#x9;     (map (lambda (sym) (Q-li-Rs-div sym ext)) syms))))&#xA;&#xA;(define resp-levl-defn&#xA;  (lambda (rsp-row)&#xA;     (element &#39;li class: &#34;response-item&#34;&#xA;&#x9;      (string-join&#xA;&#x9;       (map -  plot-label (list&#xA;&#x9;&#x9;&#x9;&#x9;  (car rsp-row)&#xA;&#x9;&#x9;&#x9;&#x9;  &#34;. &#34;&#xA;&#x9;&#x9;&#x9;&#x9;  (caddr rsp-row)))&#xA;&#x9;       &#34;&#34;))))&#xA;&#xA;(define resp-levl-list&#xA;  (lambda (defns)&#xA;    (element &#39;ol class: &#34;response-levels&#34;&#xA;&#x9;     (map resp-levl-defn (sort responses #:key car &lt;)))))&#xA;&#xA;(define output-QsRs-page&#xA;  (lambda (als plt-ext)&#xA;    (let ((yr-sr (string-join (map -  plot-label (als-ref &#39;smr als)) &#34;&#34;))&#xA;&#x9;   ;;year semetsr&#xA;&#x9;   (pge-ttl (string-append &#34;FD アンケート結果 &#34; yr-sr)))&#xA;      (call-with-output-file (build-path working-directory&#xA;                                        (string-append &#34;FD-Anketo-Questions-Result-&#34; yr-sr &#34;.html&#34;)) #:exists &#39;truncate&#xA;&#x9;&#x9;&#x9;     (lambda (out)&#xA;&#x9;&#x9;&#x9;       (output-xml (xhtml&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;    (head (title pge-ttl)&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&#x9;  (meta http-equiv: &#34;Content-Type&#34; content: &#34;text/html;charset=utf-8&#34;)&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&#x9;  (style &#34;ol.response-levels {margin-left: -1em; padding-left: 0; font-size: 11pt;&#34;)&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&#x9;  (style &#34;li.response-item {display: inline; margin-left: .5em; }&#34;)&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&#x9;  (style &#34;li {page-break-inside: avoid; } &#34;)&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&#x9;  ;; doesn&#39;t work to keep Q li and R images together&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&#x9;  (style &#34;li.ques-txt-ja { margin-left: -1.2em; font-size: 14pt; }&#34;)&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&#x9;  (style &#34;div.result-images {width: 100%;} &#34;)&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&#x9;  ;; how to shring to 100% only if auto is too wide?&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&#x9;  (style &#34;img.result-image { margin: 5px 0 10px 0 ; width:32%;  }&#34;))&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;    (body&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;     (h2 pge-ttl)&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;     (h3 &#34;回答数字の文&#34;)&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;     (resp-levl-list responses)&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;     (h3 &#34;設問の文と結果の図&#34;)&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;     (Qs-w-Rs-  ol quest-symbs plt-ext)&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;     ;; (element &#39;ol class: &#34;questions&#34;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;     ;; &#x9;   (map (lambda (sym) (Qsym-  Qli sym questions)) quest-symbs))&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;     ))&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;   out))))))&#xA;&#xA;;; output the html page&#xA;;;  needs the plot images generated beforehand, as above&#xA;;; (map (lambda (als) (anket-reslt-alist-  line-labl-chrts als quest-symbs))&#xA;;;     (list ind-als dep-als uni-als))&#xA;;; (output-QsRs-page uni-als)&#xA;&#xA;(define generate-plot-images-and-html-page&#xA;  (lambda (list-of-alists plt-ext)&#xA;    (map (lambda (als)&#xA;&#x9;   (anket-reslt-alist-  line-labl-chrts als quest-symbs))&#xA;&#x9; list-of-alists)&#xA;    (output-QsRs-page (last list-of-alists) plt-ext)))&#xA;&#xA;  (define write-plot-images-html-page-to&#xA;  (lambda (pth lst-of-alsts plt-ext)&#xA;      (generate-plot-images-and-html-page&#xA;       lst-of-alsts plt-ext)))&#xA;&#xA;;; plot-type plot extension plt-ext&#xA; (write-plot-images-html-page-to working-directory (list ind-als dep-als uni-als) page-plot-type)&#xA;  &#xA;;; svg images are lossless, the plots should look good on a wide screen and a real page.&#xA;;;  but png images are useful for sharing on-line&#xA;(define plot-bod-als-to-percentlines-countlabels-w-ext&#xA;  (lambda (BodAls  Qsyms ext)&#xA;    (let ((QR-als (dta-  Qss-Als Qsyms BodAls))&#xA;          (bod (-  plot-label (car (als-ref &#39;nme BodAls))))&#xA;          (dir  (build-path working-directory (symbol-  string ext))))   &#xA;      (define lines-percents-titled&#xA;&#x9;(lambda (QR)&#xA;&#x9;  (let ((ttl (string-append bod &#34;:&#34; (-  plot-label (car QR))))&#xA;&#x9;&#x9; (plt-ttl (string-append ttl &#34;  &#34;&#xA;                                        (string-join (map -  plot-label (als-ref &#39;cls BodAls)) &#34;T/&#34;) &#34;S&#34;))&#xA;&#x9;&#x9; (fle-name (build-path dir&#xA;                                      (string-append ttl ;; build path&#xA;                                                    (-  plot-label (car (als-ref &#39;smr BodAls)))&#xA;                                                    (-  plot-label (cadr (als-ref &#39;smr BodAls)))&#xA;                                                    &#34;.&#34; (-  plot-label ext)))))&#xA;&#x9;    (plot (list (hrule 0 #:color 0) ;; need this for stck-ngtv-rslts&#xA;&#x9;&#x9;&#x9;(lines-percents-labels-counts (cadr QR))&#xA;&#x9;&#x9;&#x9;(stck-pstv-rslts (cadr QR))&#xA;&#x9;&#x9;&#x9;(stck-ngtv-rslts (cadr QR)))&#xA;&#x9;&#x9;#:x-min .5  #:x-max 5.9&#xA;&#x9;&#x9;#:y-min -30 #:y-max 115&#xA;&#x9;&#x9;#:width 400 #:height 250&#xA;&#x9;&#x9;#:x-label &#34;levels&#34; #:y-label &#34;percent&#34;&#xA;&#x9;&#x9;#:title plt-ttl&#xA;&#x9;&#x9;#:out-file fle-name&#xA; &#x9;&#x9;#:out-kind ext))))&#xA;      (map lines-percents-titled QR-als))))&#xA;&#xA;;; need better names&#xA;(define anket-reslt-alist-  line-labl-chrts-w-ext&#xA;  (lambda (als Qsymbs ext)&#xA;    (parameterize ((plot-tick-size 3)&#xA;&#x9;&#x9;   (plot-x-far-axis? #f)&#xA;&#x9;&#x9;   (plot-y-far-axis? #f))&#xA;      (plot-bod-als-to-percentlines-countlabels-w-ext als Qsymbs ext))))&#xA;&#xA;(define write-ind-dep-uni-result-plots&#xA;  (lambda (ext-dir-sym)&#xA;    (make-or-clear-directory (symbol-  string ext-dir-sym))&#xA;      (map (lambda (als)&#xA;&#x9;     (anket-reslt-alist-  line-labl-chrts-w-ext als quest-symbs ext-dir-sym))&#xA;&#x9;   (list ind-als dep-als uni-als))&#xA;    ))&#xA;      ;;(change-directory-to wrk-dir))))&#xA;&#xA;(write-ind-dep-uni-result-plots bitmap-plot-type)&#xA;&#xA;;; after this works, make a dir, plots and page for interleaved plots&#xA;;; simple page for stacked histograms&#xA;;;  w-o 抜き procedures ... go on to roll generation too&#xA;&#xA;  Updated version of code, using Racket path utilities&#xA;     https://write.as/bs2facdev/racket-plot-faceted-view-of-questionnaire-data&#xA; #Scheme #Racket #FS4FT #FS4FD #facdev #FacultyDevelopment #DataVisualizatoin #アンケート #データ視覚化 #graph #plot #DataVisualization]]&gt;</description>
      <content:encoded><![CDATA[<p>While using questionnaire data to learn plotting, questions come to mind. Averages don&#39;t make sense for “ranked” “factors”, for numbered responses to questions about how much a person agrees or disagrees with a question. Maybe seeing the percentage and number of positive responses versus negative responses will help in the search for meaning in the data.</p>

<p><img src="https://i.snap.as/0NF5ou9.png" alt="Top of Browser page showing first two question-result sections" title="Top of Browser page showing first two question-result sections"/></p>

<p>With Racket it is possible to transform and view the data however you like. It&#39;s nice to be able to implement a view out of curiosity. I&#39;m hoping the stacked lines with their labels provide enough hints for people to figure out that they are combinations of responses of 4 and 5 in a positive direction, and 1 and 2 in a negative direction.</p>

<p><img src="https://i.snap.as/5fTLEUF.image" alt="Negative responses were most frequent for the question about student speaking, questioning in class" title="Negative responses were most frequent for the question about student speaking, questioning in class"/></p>

<p> If there is time to go over the code again there must be less repetitive way to stack negative lines after stacking positive lines. Getting started on that gave me a change to use Racket&#39;s <code>define</code> to give the <code>pnt-w-lbl</code> procedure an optional argument.</p>

<p>Years ago with gnuplot I  plotted “enthused”熱意 results against “satisified”満足 responses. Naomi Klein quoted a Harpers article by a professor that said he refused to be “cool” like a Marshall McLuhan screen.</p>

<p>For now though, I just want to see how Racket can replace two pages oddly scaled visualizations and averages. It&#39;s time to move into other work, after adjusting the css styles so that the generated page fits onto two A4 papers.</p>

<p>Here&#39;s proof that the code pasted in below worked in DrRacket:</p>

<p><img src="https://i.snap.as/VJWauWV.png" alt="DrRacket Screenshot" title="DrRacket Screenshot"/></p>



<h3 id="code">code</h3>

<pre><code>#lang racket

;; set the directory in which to write plot images
(define working-directory
  (build-path (find-system-path &#39;home-dir)
	      &#34;FD201802H30K-2B&#34;))

(unless (directory-exists? working-directory)
  (make-directory working-directory))

;; choose image extension for htmlpage
;;  the #:out-kind for plot
(define page-plot-type &#39;svg)

;; choose image extension for bitmaps
;;  #:out-kind for plot, and name of directory 
;; for bitmaps, useful to share on-line
(define bitmap-plot-type &#39;png)

(define make-or-clear-directory
  ;; can&#39;t use this with absolute directory
  (lambda (pth) ;; path, string, or list of strings ok!
    (let ((p (build-path working-directory pth))) 
      (if (directory-exists? p)
         (delete-directory/files p)
         (make-directory p)))))

(require plot) ;; discrete-histogram, stacked-histogram etc
(require plot/utils) ;; -&gt;plot-label
(require scribble/html/html) ;; for output-xml, html and class:
(require scribble/html) ;; for element

;; set the order of images in output page
(define bodies &#39;(教員 学科 大学)) ;; Teacher, Department, University

;; short keys and labels for questions and data
(define quest-symbs &#39;(出席 発言 取組 聞取 資料 時刻 反応 熱意 理解 役立 満足))

;; データを入力し直すところ
(define ind-als ;;教員の連帯リスト associative list
  &#39;((nme (教員 TCR スモール 教養)) ;; NaME of BoDy bod 体
    (smr (2018 02 H30 K)) ;; 学期 SeMesteR
    (cls (1 68))         ;; 授業、教室 CLasS
    (dta ((33 28 6 1 0)   ;; データ、DaTA
	 (8 27 19 9 5)
	 (8 25 22 12 1)
	 (37 25 6 0 0)
	 (21 34 11 2 0)
	 (49 16 3 0 0)
	 (47 16 5 0 0)
	 (56 11 1 0 0)
	 (25 31 7 5 0)
	 (17 33 15 2 1)
	 (19 38 8 2 1)))))

(define dep-als ;;学科 associative list
  &#39;((nme (学科 DPT 教養 大学))
    (smr (2018 02 H30 K))
    (cls (6 276))
    (dta ((198 59 16 3 0)
    (39 86 102 26 22)
    (50 96 90 29 9)
    (130 91 40 10 4)
    (98 107 55 12 3)
    (174 70 26 4 2)
    (125 95 48 5 3)
    (161 81 30 2 1)
    (99 114 45 13 5)
    (95 105 65 8 3)
    (89 120 51 9 7)))))

(define uni-als ;;大学
  &#39;((nme (大学 UVY 南九州 学園))
    (smr (2018 02 H30 K))
    (cls (57 2403))
    (dta ((1679 479 202 31 10)
     (419 616 974 190 199)
     (684 822 692 134 65)
     (1341 670 293 69 28)
     (1200 695 374 86 42)
     (1702 480 169 28 17)
     (1315 652 349 52 33)
     (1537 585 236 21 19)
     (938 940 412 73 34)
     (1328 676 325 43 26)
     (1172 781 356 55 34)))))

;; copied from &#34;Racket for Data Science&#34; code
;;   by Nicholas M. Van Horn,  n3mo
;;    moved by his respect for Chicken Scheme
(define als-ref
  (lambda (idx als)
    (let ((tmp (assv idx als)))
      (if tmp (cadr tmp) #f))))

(define counts-&gt;percents
  (lambda (lon) ;; list of numbers
    (let ((total (apply + lon)))
    (map (lambda (count)
	     (* (/ count total) 100.0))
	   lon))))

(define pnt-w-lbl
  (lambda (x n l (algn &#39;bottom))
    (point-label (vector x n) l #:anchor algn #:size 8)))
;; adjust font-size for big numbers here
;;  with too many digits #:angle 170 might help

(define vline-to-y
  (lambda (x y)
    (lines (map vector (list x x) (list 0 y)))))

(define vline-y1-to-y2
  (lambda (x y1 y2) ; y1 and y2 are percents
    (list
     (lines (map vector (list x x) (list 0 y1)) #:width 2)
     (lines (map vector (list x x) (list y1 y2)) #:width 3))))

(define neg-vline-y1-to-y2
  (lambda (x y1 y2) ;; y1 and y2 are percents
    (list
     (lines (map vector (list x x) (list 0 (- y1))) #:color 0 #:width 3)
     (lines (map vector (list x x) (list (- y1 ) (- y2))) #:color -1 #:width 2))))

;; 4count, 5count : 1count, 2count 
(define pos-line-label
  ;; xlevel percents, 4&#39;s count 5&#39;s count
  (lambda (x p4 p5 c4 c5)
    (let ((p4n5 (+ p4 p5))
	  (cnt-lbl (string-join (map number-&gt;string (list c4 c5)) &#34;:&#34;)))
      (list
       (pnt-w-lbl x p4n5 (-&gt;plot-label cnt-lbl))
       (vline-y1-to-y2 x p4 p4n5)))))

(define neg-line-label
  (lambda (x p1 p2 c1 c2)
    (let ((p1n2 (- (+ p1 p2)))
	  (cnt-lbl (string-join (map number-&gt;string (list c1 c2)) &#34;:&#34;)))
      (list
       (pnt-w-lbl x p1n2 (-&gt;plot-label cnt-lbl) &#39;top)
       (neg-vline-y1-to-y2 x p2 (+ p1 p2))))))

(define stck-ngtv-rslts
  (lambda (row)
    (let* ((cn1 (fifth row))
	   (cn2 (fourth row))
	   (x 5.5)
	   (pcnts (counts-&gt;percents row))
	   (pr1 (fifth pcnts))
	   (pr2 (fourth pcnts)))
      (neg-line-label x pr1 pr2 cn1 cn2))))

(define stck-pstv-rslts
  (lambda (row)
    (let* ((cn5 (first row))
	   (cn4 (second row))
	   (x 5.5) ;; #:xmax will be 5.8
	   (pcnts (counts-&gt;percents row))
	   (pr5 (first pcnts))
	   (pr4 (second pcnts)))
      (pos-line-label x pr4 pr5 cn4 cn5))))
	   
(define lines-percents-labels-counts
  ;; for each row of Question Results
  ;;  get vline-to-y and pnt-w-lbl ready for plot
  (lambda (lon)
    (let ((pcnts (counts-&gt;percents lon))
	  (lvels &#39;(5 4 3 2 1))
	  (tot-lab (-&gt;plot-label (apply + lon))))
      (append ;; need a flat list for plot
       (map (lambda (l p) ;; level percent
	      (vline-to-y l p))
	    lvels pcnts)
       (map (lambda (x n l)
	      ;; xResponse level nNumber point lLabel
	      (pnt-w-lbl x n l))
	    lvels pcnts
	    (map (lambda (s) (string-append s &#34;/&#34; tot-lab))
		 (map -&gt;plot-label lon)))))))

;; get data ready for lines-percents-labels-counts
(define dta-&gt;Qss-Als
  (lambda (Qss Als) ;; Question Symbols, A-list
    (map list Qss (als-ref &#39;dta Als))))

;; for pngs change &#34;.svg&#34; and &#39;svg to &#34;.png&#34; and &#39;png
;; below ~w-ext adds ext argument 
(define plot-bod-als-to-percentlines-countlabels
  (lambda (BodAls  Qsyms)
    ;; get orginal result data into associative list: QR-als
    (let ((QR-als (dta-&gt;Qss-Als Qsyms BodAls)) 
	   (bod (-&gt;plot-label (car (als-ref &#39;nme BodAls)))))
      (define lines-percents-titled
	(lambda (QR)
	  (let* ((ttl (string-append bod &#34;:&#34; (-&gt;plot-label (car QR))))
		 (plt-ttl (string-append ttl &#34;  &#34;
					 (string-join (map -&gt;plot-label
							   (als-ref &#39;cls BodAls)) &#34;T/&#34;) &#34;S&#34;))
		 (fle-name (build-path working-directory (string-append ttl
					  (-&gt;plot-label (car (als-ref &#39;smr BodAls)))
					  (-&gt;plot-label (cadr (als-ref &#39;smr BodAls))) &#34;.svg&#34;))))
	    (plot (list (hrule 0 #:color 0) ;; need this for stck-ngtv-rslts
			(lines-percents-labels-counts (cadr QR))
			(stck-pstv-rslts (cadr QR))
			(stck-ngtv-rslts (cadr QR)))
		#:x-min .5  #:x-max 5.9
		#:y-min -30 #:y-max 115
		#:width 400 #:height 250
		#:x-label &#34;levels&#34; #:y-label &#34;percent&#34;
		#:title plt-ttl
		#:out-file fle-name
 		#:out-kind page-plot-type))))
      (map lines-percents-titled QR-als))))

;; (define delete-dir-files
;;   (lambda (dir)
;;     (map delete-file
;; 	 (map (lambda (f) (build-path dir f))
;; 	      (directory-list dir)))))

;; need better names
(define anket-reslt-alist-&gt;line-labl-chrts
  ;; call plot-bod-als-to~~ with ink-minimizing parameters
  (lambda (als Qsymbs)
    (parameterize ((plot-tick-size 3)
		   (plot-x-far-axis? #f)
		   (plot-y-far-axis? #f))
      (plot-bod-als-to-percentlines-countlabels als Qsymbs))))

;; End of plot output, image file generationg
;; Start of html page generation
;;    using scribble/html/html

(define dir-lis-strs
  (lambda (dir)
    (let ((d (if (symbol? dir) (symbol-&gt;string dir) dir)))
    (map path-&gt;string (directory-list d)))))

(define mtchd-files
  (lambda (rxp dir)
    (filter (lambda (s) (regexp-match rxp s))
	    (dir-lis-strs dir))))
;; (mtchd-files #rx&#34;学科&#34; &#39;csv)
      
(define bod-img
  ;; regexp body, reqexp questions
  (lambda (rxB rxQ)
    ;; no dir: &#34;.&#34;
    ;; keep everything in one, current directory for now
    (filter (lambda (s) (regexp-match rxB s))
	    ;; later: (current-directory-for-user) 
	    (mtchd-files rxQ &#34;.&#34;))))  ;; working-directory
;; (bod-img #rx&#34;大学:.+svg$&#34; #rx&#34;理解&#34; &#34;.&#34;)
;; &#39;(&#34;大学:理解201801.png&#34;)

;; quest-symbs as alst keys
(define questions &#39;(
(出席 	&#34;私はこの授業によく出席した&#34;                                              学生取組)
(発言 	&#34;私は授業内容について質問や発言した&#34;                                      学生取組)
(取組 	&#34;私はこの科目に積極的に取り組んだ(予習と復習した)&#34;                      学生取組)
(聞取 	&#34;教員の声は聞き取りやすかった。&#34;                                          教員実施)
(資料 	&#34;教員の板書(またはPPT・配布資料など)は読みやすかった(見やすかった)&#34;   教員実施)
(時刻 	&#34;教員は授業の開始・終了の時刻を守ろうとしていた&#34;                          教員実施)
(反応 	&#34;教員は学生の反応を確かめながら授業を進めていた&#34;                          教員実施)
(熱意 	&#34;教員は熱意を持って授業をしていた&#34;                                        教員実施)
(理解 	&#34;私はこの授業内容を理解できた&#34;                                            総合評価)
(役立 	&#34;私はこの授業で学んだ内容はなんらかの形で将来的に役立つと感じた&#34;          総合評価)
(満足 	&#34;私は総合的に判断してこの授業で満足が得られた&#34;                            総合評価)))

(define responses &#39;((5 特に   &#34;特にそう思う&#34;       &#34;very much&#34;  &#34;I really think so&#34;)
		    (4 多少   &#34;多少そう思う&#34;	   &#34;fairly much&#34;  &#34;I somewhat think so&#34;)
		    (3 どちも &#34;どちらともいえない&#34; &#34;neither&#34;  &#34;I can&#39;t say either way&#34;)
		    (2 あまり &#34;あまりそう思わない&#34; &#34;not much&#34;  &#34;I do not think so much&#34;)
		    (1 全く   &#34;全くそう思わない&#34;   &#34;not at all&#34;  &#34;I do not think so at all&#34;)))
;; (sort responses #:key car &lt;)

(define bdy-rslt-img
  (lambda (imge-file)
    (element &#39;img class: &#34;result-image&#34; src: imge-file)))
;; (output-xml (bdy-rslt-img (bod-img #rx&#34;大学:.+svg$&#34; #rx&#34;理解&#34; &#34;.&#34;)))
;; &lt;img class=&#34;result-image&#34; src=&#34;大学:理解201801.png&#34; /&gt;

;; get list of result images in bodies order for rslt-img-div

;; regexp&lt;-symbol: rx from sym
(define symbol-&gt;regexp
  (lambda (sym)
    (regexp (symbol-&gt;string sym))))

(define make-regexp-w-ext
  (lambda (sym ext-sym)
    (regexp (string-append
             (symbol-&gt;string sym) &#34;:&#34;
             &#34;.+&#34;
             (symbol-&gt;string ext-sym) &#34;$&#34;))))

(define Qsym-Bdys-rslt-imgs
;; Question symbol, list of body symbols
  (lambda (qsym bdys ext)
    (map (lambda (bdy-rx)
	   (bod-img bdy-rx (symbol-&gt;regexp qsym)))
	 (map (lambda (bod) (make-regexp-w-ext bod ext))  bdys))))

(define rslt-img-div
  (lambda (rslt-imgs)
    (element &#39;div class: &#34;result-images&#34;
	     (map bdy-rslt-img rslt-imgs))))
;; (output-xml (rslt-img-div (Qsym-Bdys-rslt-imgs &#39;理解 bodies)))
;; &lt;div class=&#34;result-images&#34;&gt;&lt;img class=&#34;result-image&#34; src=&#34;教員:理解201801.png&#34; /&gt;&lt;img class=&#34;result-image&#34; src=&#34;学科:理解201801.png&#34; /&gt;&lt;img class=&#34;result-image&#34; src=&#34;大学:理解201801.png&#34; /&gt;&lt;/div&gt;

(define Qsym-&gt;Qli
  ;; Question-Symbol to Question item &lt;li&gt;Q&lt;/li&gt;
  (lambda (sym Qs)
    (element &#39;li class: &#34;ques-txt-ja&#34;
	     (als-ref sym Qs))))

(define Q-li-Rs-div
  ;; get Qli and image links ready for output-xml
  (lambda (sym ext)
    (list
     (Qsym-&gt;Qli sym questions)
     (rslt-img-div (Qsym-Bdys-rslt-imgs sym bodies ext)))))

(define Qs-w-Rs-&gt;ol
  ;; for output-xml get Qli and Rimages into ordered list
  (lambda (syms ext)
    (element &#39;ol class: &#34;questions-with-results&#34;
	     (map (lambda (sym) (Q-li-Rs-div sym ext)) syms))))

(define resp-levl-defn
  (lambda (rsp-row)
     (element &#39;li class: &#34;response-item&#34;
	      (string-join
	       (map -&gt;plot-label (list
				  (car rsp-row)
				  &#34;. &#34;
				  (caddr rsp-row)))
	       &#34;&#34;))))

(define resp-levl-list
  (lambda (defns)
    (element &#39;ol class: &#34;response-levels&#34;
	     (map resp-levl-defn (sort responses #:key car &lt;)))))

(define output-QsRs-page
  (lambda (als plt-ext)
    (let* ((yr-sr (string-join (map -&gt;plot-label (als-ref &#39;smr als)) &#34;&#34;))
	   ;;year semetsr
	   (pge-ttl (string-append &#34;FD アンケート結果 &#34; yr-sr)))
      (call-with-output-file (build-path working-directory
                                        (string-append &#34;FD-Anketo-Questions-Result-&#34; yr-sr &#34;.html&#34;)) #:exists &#39;truncate
			     (lambda (out)
			       (output-xml (xhtml
					    (head (title pge-ttl)
						  (meta http-equiv: &#34;Content-Type&#34; content: &#34;text/html;charset=utf-8&#34;)
						  (style &#34;ol.response-levels {margin-left: -1em; padding-left: 0; font-size: 11pt;&#34;)
						  (style &#34;li.response-item {display: inline; margin-left: .5em; }&#34;)
						  (style &#34;li {page-break-inside: avoid; } &#34;)
						  ;; doesn&#39;t work to keep Q li and R images together
						  (style &#34;li.ques-txt-ja { margin-left: -1.2em; font-size: 14pt; }&#34;)
						  (style &#34;div.result-images {width: 100%;} &#34;)
						  ;; how to shring to 100% only if auto is too wide?
						  (style &#34;img.result-image { margin: 5px 0 10px 0 ; width:32%;  }&#34;))
					    (body
					     (h2 pge-ttl)
					     (h3 &#34;回答数字の文&#34;)
					     (resp-levl-list responses)
					     (h3 &#34;設問の文と結果の図&#34;)
					     (Qs-w-Rs-&gt;ol quest-symbs plt-ext)
					     ;; (element &#39;ol class: &#34;questions&#34;
					     ;; 	   (map (lambda (sym) (Qsym-&gt;Qli sym questions)) quest-symbs))
					     ))
					   out))))))

;; output the html page
;;  needs the plot images generated beforehand, as above
;; (map (lambda (als) (anket-reslt-alist-&gt;line-labl-chrts als quest-symbs))
;;     (list ind-als dep-als uni-als))
;; (output-QsRs-page uni-als)

(define generate-plot-images-and-html-page
  (lambda (list-of-alists plt-ext)
    (map (lambda (als)
	   (anket-reslt-alist-&gt;line-labl-chrts als quest-symbs))
	 list-of-alists)
    (output-QsRs-page (last list-of-alists) plt-ext)))

  (define write-plot-images-html-page-to
  (lambda (pth lst-of-alsts plt-ext)
      (generate-plot-images-and-html-page
       lst-of-alsts plt-ext)))

;; plot-type plot extension plt-ext
 (write-plot-images-html-page-to working-directory (list ind-als dep-als uni-als) page-plot-type)
  
;; svg images are lossless, the plots should look good on a wide screen and a real page.
;;  but png images are useful for sharing on-line
(define plot-bod-als-to-percentlines-countlabels-w-ext
  (lambda (BodAls  Qsyms ext)
    (let ((QR-als (dta-&gt;Qss-Als Qsyms BodAls))
          (bod (-&gt;plot-label (car (als-ref &#39;nme BodAls))))
          (dir  (build-path working-directory (symbol-&gt;string ext))))   
      (define lines-percents-titled
	(lambda (QR)
	  (let* ((ttl (string-append bod &#34;:&#34; (-&gt;plot-label (car QR))))
		 (plt-ttl (string-append ttl &#34;  &#34;
                                        (string-join (map -&gt;plot-label (als-ref &#39;cls BodAls)) &#34;T/&#34;) &#34;S&#34;))
		 (fle-name (build-path dir
                                      (string-append ttl ;; build path
                                                    (-&gt;plot-label (car (als-ref &#39;smr BodAls)))
                                                    (-&gt;plot-label (cadr (als-ref &#39;smr BodAls)))
                                                    &#34;.&#34; (-&gt;plot-label ext)))))
	    (plot (list (hrule 0 #:color 0) ;; need this for stck-ngtv-rslts
			(lines-percents-labels-counts (cadr QR))
			(stck-pstv-rslts (cadr QR))
			(stck-ngtv-rslts (cadr QR)))
		#:x-min .5  #:x-max 5.9
		#:y-min -30 #:y-max 115
		#:width 400 #:height 250
		#:x-label &#34;levels&#34; #:y-label &#34;percent&#34;
		#:title plt-ttl
		#:out-file fle-name
 		#:out-kind ext))))
      (map lines-percents-titled QR-als))))

;; need better names
(define anket-reslt-alist-&gt;line-labl-chrts-w-ext
  (lambda (als Qsymbs ext)
    (parameterize ((plot-tick-size 3)
		   (plot-x-far-axis? #f)
		   (plot-y-far-axis? #f))
      (plot-bod-als-to-percentlines-countlabels-w-ext als Qsymbs ext))))

(define write-ind-dep-uni-result-plots
  (lambda (ext-dir-sym)
    (make-or-clear-directory (symbol-&gt;string ext-dir-sym))
      (map (lambda (als)
	     (anket-reslt-alist-&gt;line-labl-chrts-w-ext als quest-symbs ext-dir-sym))
	   (list ind-als dep-als uni-als))
    ))
      ;;(change-directory-to wrk-dir))))

(write-ind-dep-uni-result-plots bitmap-plot-type)

;; after this works, make a dir, plots and page for interleaved plots
;; simple page for stacked histograms
;;  w-o 抜き procedures ... go on to roll generation too

</code></pre>
<ul><li>Updated version of code, using Racket path utilities
<ul><li><a href="https://write.as/bs2facdev/racket-plot-faceted-view-of-questionnaire-data">https://write.as/bs2facdev/racket-plot-faceted-view-of-questionnaire-data</a>
<a href="https://write.as/bs2facdev/tag:Scheme" class="hashtag"><span>#</span><span class="p-category">Scheme</span></a> <a href="https://write.as/bs2facdev/tag:Racket" class="hashtag"><span>#</span><span class="p-category">Racket</span></a> <a href="https://write.as/bs2facdev/tag:FS4FT" class="hashtag"><span>#</span><span class="p-category">FS4FT</span></a> <a href="https://write.as/bs2facdev/tag:FS4FD" class="hashtag"><span>#</span><span class="p-category">FS4FD</span></a> <a href="https://write.as/bs2facdev/tag:facdev" class="hashtag"><span>#</span><span class="p-category">facdev</span></a> <a href="https://write.as/bs2facdev/tag:FacultyDevelopment" class="hashtag"><span>#</span><span class="p-category">FacultyDevelopment</span></a> <a href="https://write.as/bs2facdev/tag:DataVisualizatoin" class="hashtag"><span>#</span><span class="p-category">DataVisualizatoin</span></a> <a href="https://write.as/bs2facdev/tag:%E3%82%A2%E3%83%B3%E3%82%B1%E3%83%BC%E3%83%88" class="hashtag"><span>#</span><span class="p-category">アンケート</span></a> <a href="https://write.as/bs2facdev/tag:%E3%83%87%E3%83%BC%E3%82%BF%E8%A6%96%E8%A6%9A%E5%8C%96" class="hashtag"><span>#</span><span class="p-category">データ視覚化</span></a> <a href="https://write.as/bs2facdev/tag:graph" class="hashtag"><span>#</span><span class="p-category">graph</span></a> <a href="https://write.as/bs2facdev/tag:plot" class="hashtag"><span>#</span><span class="p-category">plot</span></a> <a href="https://write.as/bs2facdev/tag:DataVisualization" class="hashtag"><span>#</span><span class="p-category">DataVisualization</span></a></li></ul></li></ul>
]]></content:encoded>
      <guid>https://write.as/bs2facdev/racket-plot-stacked-lines-labeled-positive-and-negative</guid>
      <pubDate>Sat, 23 Mar 2019 15:06:39 +0000</pubDate>
    </item>
    <item>
      <title>Racket Plots to Browser Page</title>
      <link>https://write.as/bs2facdev/racket-plots-to-browser-page?pk_campaign=rss-feed</link>
      <description>&lt;![CDATA[Developing faculties for designing programs and visualization with Faculty Development Questionnaires. In the spirit of &#34;Nothing about us without us&#34;, ideally, students would design the questionnaires. We would view the data with Racket&#39;s help, and get started thinking about what sort of classes, what sort of universities, we need.&#xA;&#xA;Racket plots viewed on output page in Firefox&#xA;&#xA;It was good to get that feeling that capacities/abilities/powers were growing while doing this. Racket&#39;s documentation, DrRacket, and Emacs are great for self-directed exploratory learning. With enough time to become the equivalent of a &#34;native speaker&#34; in Racket, developing a Graded Direct Method for learning the language could be one way of developing &#34;effectively capable people&#34;(I.A. Richards). &#xA;!--more--&#xA;&#xA;理解 Understanding&#xA;&#xA;It was fun develop the script, to bring about my imagined page of Questionnaire Result visualizations while learning how to work with paths, directories and files, with scribble/html and output-xml, with regular expressions, all the little details needed to make something work. &#xA;&#xA;One of the most important thing to learn with all these hours spent coding, is that nothing is magic. Working with Scheme&#39;s associative lists provides an important experience: using built-in convenience functions like assoc or self-built convenience functions like als-ref doesn&#39;t mean you can&#39;t just use the generic &#34;primitive&#34; functions like car(first) and cdr(rest) and their variations like cadr, caddr.... Getting a feel for map list gives the ability to freely transform data into associative lists. And Racket&#39;s sort with #:key car &lt; made re-ordering the list or Response Types easy. And the using sort is a basic, widely useful, procedure. The reason sort als #:keyword car &lt; seems important is because of all the time I spent searching, learning, and re-learning how to order factors in R and the tidyverse. &#xA;&#xA;If there is a chance to work through a course in Statistics for Biology, I&#39;d rather do it in Racket than R/ggplot2. DrRacket  probably works the same on the proprietary systems the students and teachers seem stuck with for now. And writing learning journals in Racket&#39;s Scribble with DrRacket seems a lot more straightforward and widely useful than RMarkdown and knittr etc... &#xA;&#xA;DrRacket Screenshot with output-page code and plot images&#xA;&#xA;In DrRacket&#39;s Edit menu Preferences lets you get Emacs bindings, which is great for simple combinations like Ctrl-e to jump to the end of a line, but longer combinations to select all text in a buffer or switch buffers didn&#39;t work. So I&#39;ll still be developing in Emacs with Geiser-mode.&#xA;&#xA;Emacs Screenshot: Geisermode buffer and Script buffer&#xA;&#xA;I should generate two more pages, a page for just the department and the university, and a page like this one, but with the internal bodies removed from the umbrella bodies for comparison. So the teacher&#39;s data would be removed from the departments data, and the department&#39;s from the university&#39;s.  But this is enough for now. I have to go back and make Racket versions of the Guile scripts for teacher administration tasks: generating worksheets, roll-sheets, seating-charts and bureaucratic reports.  &#xA;&#xA;code&#xA;lang racket&#xA;&#xA;;; set the directory in which to write plot images&#xA;;;   and &#xA;(current-directory-for-user &#34;FD201801B&#34;)&#xA;&#xA;(require plot) ;; discrete-histogram, stacked-histogram etc&#xA;(require plot/utils) ;; -  plot-label&#xA;(require scribble/html/html) ;; for output-xml, html and class:&#xA;(require scribble/html) ;; for element&#xA;&#xA;;; set the order of images in output page&#xA;(define bodies &#39;(教員 学科 大学)) ;; Teacher, Department, University&#xA;&#xA;;; short keys and labels for questions and data&#xA;(define quest-symbs &#39;(出席 発言 取組 聞取 資料 時刻 反応 熱意 理解 役立 満足))&#xA;&#xA;;; データを入力し直すところ&#xA;(define ind-als ;;教員の連帯リスト associative list&#xA;  &#39;((nme (教員 TCR スモール 教養))&#xA;    (smr (2018 01 H30 Z)) ;; 学期 SeMesteR&#xA;    (cls (1 84))         ;; 授業、教室 CLasS&#xA;    (dta ((62 13 9 0 0)   ;; データ、DaTA&#xA;&#x9; (19 24 28 6 6)&#xA;&#x9; (23 24 27 6 4)&#xA;&#x9; (53 22 9 0 0)&#xA;&#x9; (35 29 19 0 1)&#xA;&#x9; (64 12 7 1 0)&#xA;&#x9; (54 19 10 1 0)&#xA;&#x9; (69 9 6 0 0)&#xA;&#x9; (34 28 16 4 1)&#xA;&#x9; (43 25 12 2 1)&#xA;&#x9; (35 25 20 2 1)))))&#xA;&#xA;(define dep-als ;;学科 associative list&#xA;  &#39;((nme (学科 DPT 教養 大学))&#xA;    (smr (2018 01 H30 Z))&#xA;    (cls (7 269))&#xA;    (dta ((202 41 26 0 0)&#xA;    (62 68 99 22 17)&#xA;    (72 74 98 14 11)&#xA;    (144 67 41 9 8)&#xA;    (111 78 55 13 10)&#xA;    (171 60 28 5 4)&#xA;    (140 65 46 10 8)&#xA;    (165 62 27 9 6)&#xA;    (96 98 51 14 8)&#xA;    (119 76 56 8 8)&#xA;    (109 79 60 9 10)))))&#xA;&#xA;(define uni-als ;;大学&#xA;  &#39;((nme (大学 UVY 南九州 学園))&#xA;    (smr (2018 01 H30 Z))&#xA;    (cls (59 2452))&#xA;    (dta ((1738 472 206 23 8)&#xA;     (495 549 923 195 283)&#xA;     (713 765 736 162 65)&#xA;     (1400 628 296 86 35)&#xA;     (1264 630 384 110 55)&#xA;     (1795 446 166 25 13)&#xA;     (1378 654 317 59 38)&#xA;     (1573 588 230 33 20)&#xA;     (976 886 438 99 42)&#xA;     (1411 684 289 33 24)&#xA;     (1217 740 388 58 38)))))&#xA;&#xA;;; inspired by &#34;Racket for Data Science&#34; code&#xA;;;   by Nicholas M. Van Horn,  n3mo&#xA;;;    and his respect for Chicken Scheme&#xA;(define als-ref&#xA;  (lambda (idx als)&#xA;    (let ((tmp (assv idx als)))&#xA;      (if tmp (cadr tmp) #f))))&#xA;&#xA;(define counts-  percents&#xA;  (lambda (lon) ;; list of numbers&#xA;    (let ((total (apply + lon)))&#xA;      (map (lambda (count)&#xA;&#x9;     ( (/ count total) 100.0))&#xA;&#x9;   lon))))&#xA;&#xA;(define pnt-w-lbl&#xA;  (lambda (x n l)&#xA;    (point-label (vector x n) l #:anchor &#39;bottom #:size 8)))&#xA;&#xA;(define vline-to-y&#xA;  (lambda (x y)&#xA;    (lines (map vector (list x x) (list 0 y)))))&#xA;&#xA;(define lines-percents-labels-counts&#xA;  (lambda (lon)&#xA;    (let ((pcnts (counts-  percents lon))&#xA;&#x9;  (lvels &#39;(5 4 3 2 1))&#xA;&#x9;  (tot-lab (-  plot-label (apply + lon))))&#xA;      (append ;; need a flat list for plot&#xA;       (map (lambda (l p) ;; level percent&#xA;&#x9;      (vline-to-y l p))&#xA;&#x9;    lvels pcnts)&#xA;       (map (lambda (x n l) ;; xResponse level nNumber point lLabel&#xA;&#x9;      (pnt-w-lbl x n l))&#xA;&#x9;    lvels pcnts (map (lambda (s) (string-append s &#34;/&#34; tot-lab))&#xA;&#x9;&#x9;&#x9;     (map -  plot-label lon)))))))&#xA;&#xA;;; get data ready for lines-percents-labels-counts&#xA;(define dta-  Qss-Als&#xA;  (lambda (Qss Als) ;; Question Symbols, A-list&#xA;    (map list Qss (als-ref &#39;dta Als))))&#xA;&#xA;;; for pngs change &#34;.svg&#34; and &#39;svg to &#34;.png&#34; and &#39;png ;; add ext argument &#39;svg (symbol-  string ext)&#xA;(define plot-bod-als-to-percentlines-countlabels&#xA;  (lambda (BodAls  Qsyms)&#xA;    (let ((QR-als (dta-  Qss-Als Qsyms BodAls))&#xA;&#x9;   (bod (-  plot-label (car (als-ref &#39;nme BodAls)))))&#xA;      (define lines-percents-titled&#xA;&#x9;(lambda (QR)&#xA;&#x9;  (let ((ttl (string-append bod &#34;:&#34; (-  plot-label (car QR))))&#xA;&#x9;&#x9; (plt-ttl (string-append ttl &#34;  &#34; (string-join (map -  plot-label (als-ref &#39;cls BodAls)) &#34;T/&#34;) &#34;S&#34;))&#xA;&#x9;&#x9; (fle-name (string-append ttl (-  plot-label (car (als-ref &#39;smr BodAls))) (-  plot-label (cadr (als-ref &#39;smr BodAls))) &#34;.svg&#34;)))&#xA;&#x9;    (plot (lines-percents-labels-counts (cadr QR))&#xA;&#x9;&#x9;#:x-min .2 &#xA;&#x9;&#x9;#:x-max 5.8 #:y-max 100  &#xA;&#x9;&#x9;#:width 400 #:height 250&#xA;&#x9;&#x9;#:x-label &#34;levels&#34; #:y-label &#34;percent&#34;&#xA;&#x9;&#x9;#:title plt-ttl&#xA;&#x9;&#x9;#:out-file fle-name&#xA; &#x9;&#x9;#:out-kind &#39;svg))))&#xA;      (map lines-percents-titled QR-als))))&#xA;&#xA;;; need better names&#xA;(define anket-reslt-alist-  line-labl-chrts&#xA;  (lambda (als Qsymbs)&#xA;    (parameterize ((plot-tick-size 3)&#xA;&#x9;&#x9;   (plot-x-far-axis? #f)&#xA;&#x9;&#x9;   (plot-y-far-axis? #f))&#xA;      (plot-bod-als-to-percentlines-countlabels als Qsymbs))))&#xA;&#xA;;; execting plot-bod-als-to-percentlines-countlabels and&#xA;;;           anket-reslt-alist-  line-labl-chrts&#xA;;; This is needed before the call to output-QsRs-page &#xA;(map (lambda (als) (anket-reslt-alist-  line-labl-chrts als quest-symbs))&#xA;     (list ind-als dep-als uni-als))&#xA;;; 教員:理解201801.png 学科:役立201801.png 大学:資料201801.png&#xA;&#xA;;; End of plot output, image file generationg&#xA;;; Start of html page generation&#xA;;;    using scribble/html/html&#xA;&#xA;(define dir-lis-strs&#xA;  (lambda (dir)&#xA;    (let ((d (if (symbol? dir) (symbol-  string dir) dir)))&#xA;    (map path-  string (directory-list d)))))&#xA;&#xA;(define mtchd-files&#xA;  (lambda (rxp dir)&#xA;    (filter (lambda (s) (regexp-match rxp s))&#xA;&#x9;    (dir-lis-strs dir))))&#xA;;; (mtchd-files #rx&#34;学科&#34; &#39;csv)&#xA;&#xA;(define bod-img&#xA;  ;; regexp body, reqexp questions&#xA;  (lambda (rxB rxQ)&#xA;    ;; no dir: &#34;.&#34;&#xA;    ;; keep everything in one, current directory for now&#xA;    (filter (lambda (s) (regexp-match rxB s))&#xA;&#x9;    (mtchd-files rxQ &#34;.&#34;))))&#xA;;; (bod-img #rx&#34;大学&#34; #rx&#34;理解&#34; &#34;.&#34;)&#xA;;; &#39;(&#34;大学:理解201801.png&#34;)&#xA;&#xA;;; quest-symbs as alst keys&#xA;(define questions &#39;(&#xA;(出席 &#x9;&#34;私はこの授業によく出席した&#34;                                              学生取組)&#xA;(発言 &#x9;&#34;私は授業内容について質問や発言した&#34;                                      学生取組)&#xA;(取組 &#x9;&#34;私はこの科目に積極的に取り組んだ(予習と復習した)&#34;                      学生取組)&#xA;(聞取 &#x9;&#34;教員の声は聞き取りやすかった。&#34;                                          教員実施)&#xA;(資料 &#x9;&#34;教員の板書（またはPPT・配布資料など）は読みやすかった（見やすかった）&#34;   教員実施)&#xA;(時刻 &#x9;&#34;教員は授業の開始・終了の時刻を守ろうとしていた&#34;                          教員実施)&#xA;(反応 &#x9;&#34;教員は学生の反応を確かめながら授業を進めていた&#34;                          教員実施)&#xA;(熱意 &#x9;&#34;教員は熱意を持って授業をしていた&#34;                                        教員実施)&#xA;(理解 &#x9;&#34;私はこの授業内容を理解できた&#34;                                            総合評価)&#xA;(役立 &#x9;&#34;私はこの授業で学んだ内容はなんらかの形で将来的に役立つと感じた&#34;          総合評価)&#xA;(満足 &#x9;&#34;私は総合的に判断してこの授業で満足が得られた&#34;                            総合評価)))&#xA;&#xA;(define responses &#39;((5 特に   &#34;特にそう思う&#34;       &#34;very much&#34;  &#34;I really think so&#34;)&#xA;&#x9;&#x9;    (4 多少   &#34;多少そう思う&#34;&#x9;   &#34;fairly much&#34;  &#34;I somewhat think so&#34;)&#xA;&#x9;&#x9;    (3 どちも &#34;どちらともいえない&#34; &#34;neither&#34;  &#34;I can&#39;t say either way&#34;)&#xA;&#x9;&#x9;    (2 あまり &#34;あまりそう思わない&#34; &#34;not much&#34;  &#34;I do not think so much&#34;)&#xA;&#x9;&#x9;    (1 全く   &#34;全くそう思わない&#34;   &#34;not at all&#34;  &#34;I do not think so at all&#34;)))&#xA;;; (sort responses #:key car &lt;)&#xA;&#xA;(define bdy-rslt-img&#xA;  (lambda (imge-file)&#xA;    (element &#39;img class: &#34;result-image&#34; src: imge-file)))&#xA;;; (output-xml (bdy-rslt-img (bod-img #rx&#34;大学:&#34; #rx&#34;理解&#34; &#34;.&#34;)))&#xA;;; img class=&#34;result-image&#34; src=&#34;大学:理解201801.png&#34; /&#xA;&#xA;;; get list of result images in bodies order for rslt-img-div&#xA;&#xA;(define symbol-  regexp&#xA;  (lambda (sym)&#xA;    (regexp (symbol-  string sym))))&#xA;;; Question symbol, list of body symbols&#xA;(define Qsym-Bdys-rslt-imgs&#xA;  (lambda (qsym bdys)&#xA;    (map (lambda (bdy-rx)&#xA;&#x9;   (bod-img bdy-rx (symbol-  regexp qsym)))&#xA;&#x9; (map symbol-  regexp bdys))))&#xA;(define rslt-img-div&#xA;  (lambda (rslt-imgs)&#xA;    (element &#39;div class: &#34;result-images&#34;&#xA;&#x9;     (map bdy-rslt-img rslt-imgs))))&#xA;;; (output-xml (rslt-img-div (Qsym-Bdys-rslt-imgs &#39;理解 bodies)))&#xA;;; div class=&#34;result-images&#34;img class=&#34;result-image&#34; src=&#34;教員:理解201801.png&#34; /img class=&#34;result-image&#34; src=&#34;学科:理解201801.png&#34; /img class=&#34;result-image&#34; src=&#34;大学:理解201801.png&#34; //div&#xA;(define Qsym-  Qli&#xA;  (lambda (sym Qs)&#xA;    (element &#39;li class: &#34;ques-txt-ja&#34;&#xA;&#x9;     (als-ref sym Qs))))&#xA;(define Q-li-Rs-div&#xA;  (lambda (sym)&#xA;    (list&#xA;     (Qsym-  Qli sym questions)&#xA;     (rslt-img-div (Qsym-Bdys-rslt-imgs sym bodies)))))&#xA;(define Qs-w-Rs-  ol&#xA;  (lambda (syms)&#xA;    (element &#39;ol class: &#34;questions-with-results&#34;&#xA;&#x9;     (map Q-li-Rs-div syms))))&#xA;&#xA;(define resp-levl-defn&#xA;  (lambda (rsp-row)&#xA;     (element &#39;li class: &#34;response-item&#34;&#xA;&#x9;      (string-join&#xA;&#x9;       (map -  plot-label (list&#xA;&#x9;&#x9;&#x9;&#x9;  (car rsp-row)&#xA;&#x9;&#x9;&#x9;&#x9;  &#34;. &#34;&#xA;&#x9;&#x9;&#x9;&#x9;  (caddr rsp-row)))&#xA;&#x9;       &#34;&#34;))))&#xA;&#xA;(define resp-levl-list&#xA;  (lambda (defns)&#xA;    (element &#39;ol class: &#34;response-levels&#34;&#xA;&#x9;     (map resp-levl-defn (sort responses #:key car &lt;)))))&#xA;&#xA;(define output-QsRs-page&#xA;  (lambda (als)&#xA;    (let ((yr-sr (string-join (map -  plot-label (als-ref &#39;smr als)) &#34;&#34;))&#xA;&#x9;   ;;year semetsr&#xA;&#x9;   (pge-ttl (string-append &#34;FD アンケート結果 &#34; yr-sr)))&#xA;      (call-with-output-file (string-append &#34;FD-Anketo-Questions-Result-&#34; yr-sr &#34;.html&#34;) #:exists &#39;truncate&#xA;&#x9;&#x9;&#x9;     (lambda (out)&#xA;&#x9;&#x9;&#x9;       (output-xml (xhtml&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;    (head (title pge-ttl)&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&#x9;  (meta http-equiv: &#34;Content-Type&#34; content: &#34;text/html;charset=utf-8&#34;)&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&#x9;  (style &#34;ol.response-levels {margin-left: -.8em; padding-left: 0; font-size: 11pt;&#34;)&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&#x9;  (style &#34;li.response-item {display: inline; margin-left: .5em; }&#34;)&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&#x9;  (style &#34;li {page-break-inside: avoid; } &#34;)&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&#x9;  ;; doesn&#39;t work to keep Q li and R images together&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&#x9;  (style &#34;li.ques-txt-ja { margin-left: -.8em; font-size: 14pt; }&#34;)&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&#x9;  (style &#34;div.result-images {width: 100%;} &#34;)&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&#x9;  ;; how to shring to 100% only if auto is too wide?&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&#x9;  (style &#34;img.result-image { margin: 5px 0 10px 0 ; width:32%;  }&#34;))&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;    (body&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;     (h2 pge-ttl)&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;     (h3 &#34;回答数字の文&#34;)&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;     (resp-levl-list responses)&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;     (h3 &#34;設問の文と結果の図&#34;)&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;     (Qs-w-Rs-  ol quest-symbs)&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;     ;; (element &#39;ol class: &#34;questions&#34;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;     ;; &#x9;   (map (lambda (sym) (Qsym-  Qli sym questions)) quest-symbs))&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;     ))&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;   out))))))&#xA;&#xA;;; output the html page&#xA;;;  needs the plot images generated beforehand, as above&#xA;;; (map (lambda (als) (anket-reslt-alist-  line-labl-chrts als quest-symbs))&#xA;;;     (list ind-als dep-als uni-als))&#xA;(output-QsRs-page uni-als)&#xA;&#xA;;; svg images are lossless, the plots should look good on a wide screen and a real page.&#xA;;;  but png images are useful for sharing on-line&#xA;(define plot-bod-als-to-percentlines-countlabels-w-ext&#xA;  (lambda (BodAls  Qsyms ext)&#xA;    (let ((QR-als (dta-  Qss-Als Qsyms BodAls))&#xA;&#x9;   (bod (-  plot-label (car (als-ref &#39;nme BodAls)))))&#xA;      (define lines-percents-titled&#xA;&#x9;(lambda (QR)&#xA;&#x9;  (let ((ttl (string-append bod &#34;:&#34; (-  plot-label (car QR))))&#xA;&#x9;&#x9; (plt-ttl (string-append ttl &#34;  &#34; (string-join (map -  plot-label (als-ref &#39;cls BodAls)) &#34;T/&#34;) &#34;S&#34;))&#xA;&#x9;&#x9; (fle-name (string-append ttl (-  plot-label (car (als-ref &#39;smr BodAls))) (-  plot-label (cadr (als-ref &#39;smr BodAls)))&#xA;                                         &#34;.&#34; (-  plot-label ext))))&#xA;&#x9;    (plot (lines-percents-labels-counts (cadr QR))&#xA;&#x9;&#x9;#:x-min .2 &#xA;&#x9;&#x9;#:x-max 5.8 #:y-max 100  &#xA;&#x9;&#x9;#:width 400 #:height 250&#xA;&#x9;&#x9;#:x-label &#34;levels&#34; #:y-label &#34;percent&#34;&#xA;&#x9;&#x9;#:title plt-ttl&#xA;&#x9;&#x9;#:out-file fle-name&#xA; &#x9;&#x9;#:out-kind ext))))&#xA;      (map lines-percents-titled QR-als))))&#xA;&#xA;;; need better names&#xA;(define anket-reslt-alist-  line-labl-chrts-w-ext&#xA;  (lambda (als Qsymbs ext)&#xA;    (parameterize ((plot-tick-size 3)&#xA;&#x9;&#x9;   (plot-x-far-axis? #f)&#xA;&#x9;&#x9;   (plot-y-far-axis? #f))&#xA;      (plot-bod-als-to-percentlines-countlabels-w-ext als Qsymbs ext))))&#xA;&#xA;(if (directory-exists? &#34;pngs&#34;)&#xA;   (map delete-file (map (lambda (f) (build-path &#34;pngs&#34; f))&#xA;                        (directory-list &#34;pngs&#34;)))&#xA;   (make-directory &#34;pngs&#34;))&#xA;&#xA;(current-directory &#34;pngs&#34;);; I don&#39;t know why I need this... &#xA;(current-directory-for-user &#34;pngs&#34;)&#xA;(map (lambda (als) (anket-reslt-alist-  line-labl-chrts-w-ext als quest-symbs &#39;png))&#xA;     (list ind-als dep-als uni-als))&#xA;&#xA; More images:  https://snap.as/bsmall2/racket-plot-2-output-page&#xA;&#xA; #Scheme #Racket #FS4FT #FS4FD #facdev #FacultyDevelopment #DataVisualizatoin #アンケート #データ視覚化&#xA;&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p>Developing faculties for designing programs and visualization with Faculty Development Questionnaires. In the spirit of “Nothing about us without us”, ideally, students would design the questionnaires. We would view the data with Racket&#39;s help, and get started thinking about what sort of classes, what sort of universities, we need.</p>

<p><img src="https://i.snap.as/htwQSe1.jpg" alt="Racket plots viewed on output page in Firefox" title="Racket plots viewed on output page in Firefox"/></p>

<p>It was good to get that feeling that capacities/abilities/powers were growing while doing this. Racket&#39;s documentation, DrRacket, and Emacs are great for self-directed exploratory learning. With enough time to become the equivalent of a “native speaker” in Racket, developing a <em>Graded Direct Method</em> for learning the language could be one way of developing “effectively capable people”(I.A. Richards).
</p>

<p><img src="https://i.snap.as/FvxjQBk.image" alt="理解 Understanding" title="理解 Understanding"/></p>

<p>It was fun develop the script, to bring about my imagined page of Questionnaire Result visualizations while learning how to work with paths, directories and files, with scribble/html and output-xml, with regular expressions, all the little details needed to make something work.</p>

<p>One of the most important thing to learn with all these hours spent coding, is that nothing is magic. Working with Scheme&#39;s associative lists provides an important experience: using built-in convenience functions like <code>assoc</code> or self-built convenience functions like <code>als-ref</code> doesn&#39;t mean you can&#39;t just use the generic “primitive” functions like <code>car</code>(first) and <code>cdr</code>(rest) and their variations like <code>cadr</code>, <code>caddr</code>.... Getting a feel for <code>map list</code> gives the ability to freely transform data into associative lists. And Racket&#39;s <code>sort</code> with <code>#:key car &lt;</code> made re-ordering the list or Response Types easy. And the using <code>sort</code> is a basic, widely useful, procedure. The reason <code>sort als #:keyword car &lt;</code> seems important is because of all the time I spent searching, learning, and re-learning how to order factors in R and the tidyverse.</p>

<p>If there is a chance to work through a course in Statistics for Biology, I&#39;d rather do it in Racket than R/ggplot2. DrRacket  probably works the same on the proprietary systems the students and teachers seem stuck with for now. And writing learning journals in Racket&#39;s Scribble with DrRacket seems a lot more straightforward and widely useful than RMarkdown and knittr etc...</p>

<p><img src="https://i.snap.as/2ipGvv1.jpg" alt="DrRacket Screenshot with output-page code and plot images" title="DrRacket Screenshot with output-page code and plot images"/></p>

<p>In DrRacket&#39;s Edit menu Preferences lets you get Emacs bindings, which is great for simple combinations like <code>Ctrl</code>-<code>e</code> to jump to the end of a line, but longer combinations to select all text in a buffer or switch buffers didn&#39;t work. So I&#39;ll still be developing in Emacs with Geiser-mode.</p>

<p><img src="https://i.snap.as/7MRKn60.jpg" alt="Emacs Screenshot: Geisermode buffer and Script buffer" title="Emacs Screenshot: Geisermode buffer with data and plot code, and a Script buffer with two procedures"/></p>

<p>I should generate two more pages, a page for just the department and the university, and a page like this one, but with the internal bodies removed from the umbrella bodies for comparison. So the teacher&#39;s data would be removed from the departments data, and the department&#39;s from the university&#39;s.  But this is enough for now. I have to go back and make Racket versions of the Guile scripts for teacher administration tasks: generating worksheets, roll-sheets, seating-charts and bureaucratic reports.</p>

<h3 id="code">code</h3>

<pre><code>#lang racket

;; set the directory in which to write plot images
;;   and 
(current-directory-for-user &#34;FD201801B&#34;)

(require plot) ;; discrete-histogram, stacked-histogram etc
(require plot/utils) ;; -&gt;plot-label
(require scribble/html/html) ;; for output-xml, html and class:
(require scribble/html) ;; for element

;; set the order of images in output page
(define bodies &#39;(教員 学科 大学)) ;; Teacher, Department, University

;; short keys and labels for questions and data
(define quest-symbs &#39;(出席 発言 取組 聞取 資料 時刻 反応 熱意 理解 役立 満足))

;; データを入力し直すところ
(define ind-als ;;教員の連帯リスト associative list
  &#39;((nme (教員 TCR スモール 教養))
    (smr (2018 01 H30 Z)) ;; 学期 SeMesteR
    (cls (1 84))         ;; 授業、教室 CLasS
    (dta ((62 13 9 0 0)   ;; データ、DaTA
	 (19 24 28 6 6)
	 (23 24 27 6 4)
	 (53 22 9 0 0)
	 (35 29 19 0 1)
	 (64 12 7 1 0)
	 (54 19 10 1 0)
	 (69 9 6 0 0)
	 (34 28 16 4 1)
	 (43 25 12 2 1)
	 (35 25 20 2 1)))))

(define dep-als ;;学科 associative list
  &#39;((nme (学科 DPT 教養 大学))
    (smr (2018 01 H30 Z))
    (cls (7 269))
    (dta ((202 41 26 0 0)
    (62 68 99 22 17)
    (72 74 98 14 11)
    (144 67 41 9 8)
    (111 78 55 13 10)
    (171 60 28 5 4)
    (140 65 46 10 8)
    (165 62 27 9 6)
    (96 98 51 14 8)
    (119 76 56 8 8)
    (109 79 60 9 10)))))

(define uni-als ;;大学
  &#39;((nme (大学 UVY 南九州 学園))
    (smr (2018 01 H30 Z))
    (cls (59 2452))
    (dta ((1738 472 206 23 8)
     (495 549 923 195 283)
     (713 765 736 162 65)
     (1400 628 296 86 35)
     (1264 630 384 110 55)
     (1795 446 166 25 13)
     (1378 654 317 59 38)
     (1573 588 230 33 20)
     (976 886 438 99 42)
     (1411 684 289 33 24)
     (1217 740 388 58 38)))))

;; inspired by &#34;Racket for Data Science&#34; code
;;   by Nicholas M. Van Horn,  n3mo
;;    and his respect for Chicken Scheme
(define als-ref
  (lambda (idx als)
    (let ((tmp (assv idx als)))
      (if tmp (cadr tmp) #f))))

(define counts-&gt;percents
  (lambda (lon) ;; list of numbers
    (let ((total (apply + lon)))
      (map (lambda (count)
	     (* (/ count total) 100.0))
	   lon))))

(define pnt-w-lbl
  (lambda (x n l)
    (point-label (vector x n) l #:anchor &#39;bottom #:size 8)))

(define vline-to-y
  (lambda (x y)
    (lines (map vector (list x x) (list 0 y)))))

(define lines-percents-labels-counts
  (lambda (lon)
    (let ((pcnts (counts-&gt;percents lon))
	  (lvels &#39;(5 4 3 2 1))
	  (tot-lab (-&gt;plot-label (apply + lon))))
      (append ;; need a flat list for plot
       (map (lambda (l p) ;; level percent
	      (vline-to-y l p))
	    lvels pcnts)
       (map (lambda (x n l) ;; xResponse level nNumber point lLabel
	      (pnt-w-lbl x n l))
	    lvels pcnts (map (lambda (s) (string-append s &#34;/&#34; tot-lab))
			     (map -&gt;plot-label lon)))))))

;; get data ready for lines-percents-labels-counts
(define dta-&gt;Qss-Als
  (lambda (Qss Als) ;; Question Symbols, A-list
    (map list Qss (als-ref &#39;dta Als))))

;; for pngs change &#34;.svg&#34; and &#39;svg to &#34;.png&#34; and &#39;png ;; add ext argument &#39;svg (symbol-&gt;string ext)
(define plot-bod-als-to-percentlines-countlabels
  (lambda (BodAls  Qsyms)
    (let ((QR-als (dta-&gt;Qss-Als Qsyms BodAls))
	   (bod (-&gt;plot-label (car (als-ref &#39;nme BodAls)))))
      (define lines-percents-titled
	(lambda (QR)
	  (let* ((ttl (string-append bod &#34;:&#34; (-&gt;plot-label (car QR))))
		 (plt-ttl (string-append ttl &#34;  &#34; (string-join (map -&gt;plot-label (als-ref &#39;cls BodAls)) &#34;T/&#34;) &#34;S&#34;))
		 (fle-name (string-append ttl (-&gt;plot-label (car (als-ref &#39;smr BodAls))) (-&gt;plot-label (cadr (als-ref &#39;smr BodAls))) &#34;.svg&#34;)))
	    (plot (lines-percents-labels-counts (cadr QR))
		#:x-min .2 
		#:x-max 5.8 #:y-max 100  
		#:width 400 #:height 250
		#:x-label &#34;levels&#34; #:y-label &#34;percent&#34;
		#:title plt-ttl
		#:out-file fle-name
 		#:out-kind &#39;svg))))
      (map lines-percents-titled QR-als))))

;; need better names
(define anket-reslt-alist-&gt;line-labl-chrts
  (lambda (als Qsymbs)
    (parameterize ((plot-tick-size 3)
		   (plot-x-far-axis? #f)
		   (plot-y-far-axis? #f))
      (plot-bod-als-to-percentlines-countlabels als Qsymbs))))

;; execting plot-bod-als-to-percentlines-countlabels and
;;           anket-reslt-alist-&gt;line-labl-chrts
;; This is needed before the call to output-QsRs-page 
(map (lambda (als) (anket-reslt-alist-&gt;line-labl-chrts als quest-symbs))
     (list ind-als dep-als uni-als))
;; 教員:理解201801.png 学科:役立201801.png 大学:資料201801.png

;; End of plot output, image file generationg
;; Start of html page generation
;;    using scribble/html/html

(define dir-lis-strs
  (lambda (dir)
    (let ((d (if (symbol? dir) (symbol-&gt;string dir) dir)))
    (map path-&gt;string (directory-list d)))))

(define mtchd-files
  (lambda (rxp dir)
    (filter (lambda (s) (regexp-match rxp s))
	    (dir-lis-strs dir))))
;; (mtchd-files #rx&#34;学科&#34; &#39;csv)

(define bod-img
  ;; regexp body, reqexp questions
  (lambda (rxB rxQ)
    ;; no dir: &#34;.&#34;
    ;; keep everything in one, current directory for now
    (filter (lambda (s) (regexp-match rxB s))
	    (mtchd-files rxQ &#34;.&#34;))))
;; (bod-img #rx&#34;大学&#34; #rx&#34;理解&#34; &#34;.&#34;)
;; &#39;(&#34;大学:理解201801.png&#34;)

;; quest-symbs as alst keys
(define questions &#39;(
(出席 	&#34;私はこの授業によく出席した&#34;                                              学生取組)
(発言 	&#34;私は授業内容について質問や発言した&#34;                                      学生取組)
(取組 	&#34;私はこの科目に積極的に取り組んだ(予習と復習した)&#34;                      学生取組)
(聞取 	&#34;教員の声は聞き取りやすかった。&#34;                                          教員実施)
(資料 	&#34;教員の板書（またはPPT・配布資料など）は読みやすかった（見やすかった）&#34;   教員実施)
(時刻 	&#34;教員は授業の開始・終了の時刻を守ろうとしていた&#34;                          教員実施)
(反応 	&#34;教員は学生の反応を確かめながら授業を進めていた&#34;                          教員実施)
(熱意 	&#34;教員は熱意を持って授業をしていた&#34;                                        教員実施)
(理解 	&#34;私はこの授業内容を理解できた&#34;                                            総合評価)
(役立 	&#34;私はこの授業で学んだ内容はなんらかの形で将来的に役立つと感じた&#34;          総合評価)
(満足 	&#34;私は総合的に判断してこの授業で満足が得られた&#34;                            総合評価)))

(define responses &#39;((5 特に   &#34;特にそう思う&#34;       &#34;very much&#34;  &#34;I really think so&#34;)
		    (4 多少   &#34;多少そう思う&#34;	   &#34;fairly much&#34;  &#34;I somewhat think so&#34;)
		    (3 どちも &#34;どちらともいえない&#34; &#34;neither&#34;  &#34;I can&#39;t say either way&#34;)
		    (2 あまり &#34;あまりそう思わない&#34; &#34;not much&#34;  &#34;I do not think so much&#34;)
		    (1 全く   &#34;全くそう思わない&#34;   &#34;not at all&#34;  &#34;I do not think so at all&#34;)))
;; (sort responses #:key car &lt;)

(define bdy-rslt-img
  (lambda (imge-file)
    (element &#39;img class: &#34;result-image&#34; src: imge-file)))
;; (output-xml (bdy-rslt-img (bod-img #rx&#34;大学:&#34; #rx&#34;理解&#34; &#34;.&#34;)))
;; &lt;img class=&#34;result-image&#34; src=&#34;大学:理解201801.png&#34; /&gt;

;; get list of result images in bodies order for rslt-img-div

(define symbol-&gt;regexp
  (lambda (sym)
    (regexp (symbol-&gt;string sym))))
;; Question symbol, list of body symbols
(define Qsym-Bdys-rslt-imgs
  (lambda (qsym bdys)
    (map (lambda (bdy-rx)
	   (bod-img bdy-rx (symbol-&gt;regexp qsym)))
	 (map symbol-&gt;regexp bdys))))
(define rslt-img-div
  (lambda (rslt-imgs)
    (element &#39;div class: &#34;result-images&#34;
	     (map bdy-rslt-img rslt-imgs))))
;; (output-xml (rslt-img-div (Qsym-Bdys-rslt-imgs &#39;理解 bodies)))
;; &lt;div class=&#34;result-images&#34;&gt;&lt;img class=&#34;result-image&#34; src=&#34;教員:理解201801.png&#34; /&gt;&lt;img class=&#34;result-image&#34; src=&#34;学科:理解201801.png&#34; /&gt;&lt;img class=&#34;result-image&#34; src=&#34;大学:理解201801.png&#34; /&gt;&lt;/div&gt;
(define Qsym-&gt;Qli
  (lambda (sym Qs)
    (element &#39;li class: &#34;ques-txt-ja&#34;
	     (als-ref sym Qs))))
(define Q-li-Rs-div
  (lambda (sym)
    (list
     (Qsym-&gt;Qli sym questions)
     (rslt-img-div (Qsym-Bdys-rslt-imgs sym bodies)))))
(define Qs-w-Rs-&gt;ol
  (lambda (syms)
    (element &#39;ol class: &#34;questions-with-results&#34;
	     (map Q-li-Rs-div syms))))

(define resp-levl-defn
  (lambda (rsp-row)
     (element &#39;li class: &#34;response-item&#34;
	      (string-join
	       (map -&gt;plot-label (list
				  (car rsp-row)
				  &#34;. &#34;
				  (caddr rsp-row)))
	       &#34;&#34;))))

(define resp-levl-list
  (lambda (defns)
    (element &#39;ol class: &#34;response-levels&#34;
	     (map resp-levl-defn (sort responses #:key car &lt;)))))

(define output-QsRs-page
  (lambda (als)
    (let* ((yr-sr (string-join (map -&gt;plot-label (als-ref &#39;smr als)) &#34;&#34;))
	   ;;year semetsr
	   (pge-ttl (string-append &#34;FD アンケート結果 &#34; yr-sr)))
      (call-with-output-file (string-append &#34;FD-Anketo-Questions-Result-&#34; yr-sr &#34;.html&#34;) #:exists &#39;truncate
			     (lambda (out)
			       (output-xml (xhtml
					    (head (title pge-ttl)
						  (meta http-equiv: &#34;Content-Type&#34; content: &#34;text/html;charset=utf-8&#34;)
						  (style &#34;ol.response-levels {margin-left: -.8em; padding-left: 0; font-size: 11pt;&#34;)
						  (style &#34;li.response-item {display: inline; margin-left: .5em; }&#34;)
						  (style &#34;li {page-break-inside: avoid; } &#34;)
						  ;; doesn&#39;t work to keep Q li and R images together
						  (style &#34;li.ques-txt-ja { margin-left: -.8em; font-size: 14pt; }&#34;)
						  (style &#34;div.result-images {width: 100%;} &#34;)
						  ;; how to shring to 100% only if auto is too wide?
						  (style &#34;img.result-image { margin: 5px 0 10px 0 ; width:32%;  }&#34;))
					    (body
					     (h2 pge-ttl)
					     (h3 &#34;回答数字の文&#34;)
					     (resp-levl-list responses)
					     (h3 &#34;設問の文と結果の図&#34;)
					     (Qs-w-Rs-&gt;ol quest-symbs)
					     ;; (element &#39;ol class: &#34;questions&#34;
					     ;; 	   (map (lambda (sym) (Qsym-&gt;Qli sym questions)) quest-symbs))
					     ))
					   out))))))

;; output the html page
;;  needs the plot images generated beforehand, as above
;; (map (lambda (als) (anket-reslt-alist-&gt;line-labl-chrts als quest-symbs))
;;     (list ind-als dep-als uni-als))
(output-QsRs-page uni-als)

;; svg images are lossless, the plots should look good on a wide screen and a real page.
;;  but png images are useful for sharing on-line
(define plot-bod-als-to-percentlines-countlabels-w-ext
  (lambda (BodAls  Qsyms ext)
    (let ((QR-als (dta-&gt;Qss-Als Qsyms BodAls))
	   (bod (-&gt;plot-label (car (als-ref &#39;nme BodAls)))))
      (define lines-percents-titled
	(lambda (QR)
	  (let* ((ttl (string-append bod &#34;:&#34; (-&gt;plot-label (car QR))))
		 (plt-ttl (string-append ttl &#34;  &#34; (string-join (map -&gt;plot-label (als-ref &#39;cls BodAls)) &#34;T/&#34;) &#34;S&#34;))
		 (fle-name (string-append ttl (-&gt;plot-label (car (als-ref &#39;smr BodAls))) (-&gt;plot-label (cadr (als-ref &#39;smr BodAls)))
                                         &#34;.&#34; (-&gt;plot-label ext))))
	    (plot (lines-percents-labels-counts (cadr QR))
		#:x-min .2 
		#:x-max 5.8 #:y-max 100  
		#:width 400 #:height 250
		#:x-label &#34;levels&#34; #:y-label &#34;percent&#34;
		#:title plt-ttl
		#:out-file fle-name
 		#:out-kind ext))))
      (map lines-percents-titled QR-als))))

;; need better names
(define anket-reslt-alist-&gt;line-labl-chrts-w-ext
  (lambda (als Qsymbs ext)
    (parameterize ((plot-tick-size 3)
		   (plot-x-far-axis? #f)
		   (plot-y-far-axis? #f))
      (plot-bod-als-to-percentlines-countlabels-w-ext als Qsymbs ext))))

(if (directory-exists? &#34;pngs&#34;)
   (map delete-file (map (lambda (f) (build-path &#34;pngs&#34; f))
                        (directory-list &#34;pngs&#34;)))
   (make-directory &#34;pngs&#34;))

(current-directory &#34;pngs&#34;);; I don&#39;t know why I need this... 
(current-directory-for-user &#34;pngs&#34;)
(map (lambda (als) (anket-reslt-alist-&gt;line-labl-chrts-w-ext als quest-symbs &#39;png))
     (list ind-als dep-als uni-als))

</code></pre>
<ul><li>More images:  <a href="https://snap.as/bsmall2/racket-plot-2-output-page">https://snap.as/bsmall2/racket-plot-2-output-page</a></li></ul>

<p> <a href="https://write.as/bs2facdev/tag:Scheme" class="hashtag"><span>#</span><span class="p-category">Scheme</span></a> <a href="https://write.as/bs2facdev/tag:Racket" class="hashtag"><span>#</span><span class="p-category">Racket</span></a> <a href="https://write.as/bs2facdev/tag:FS4FT" class="hashtag"><span>#</span><span class="p-category">FS4FT</span></a> <a href="https://write.as/bs2facdev/tag:FS4FD" class="hashtag"><span>#</span><span class="p-category">FS4FD</span></a> <a href="https://write.as/bs2facdev/tag:facdev" class="hashtag"><span>#</span><span class="p-category">facdev</span></a> <a href="https://write.as/bs2facdev/tag:FacultyDevelopment" class="hashtag"><span>#</span><span class="p-category">FacultyDevelopment</span></a> <a href="https://write.as/bs2facdev/tag:DataVisualizatoin" class="hashtag"><span>#</span><span class="p-category">DataVisualizatoin</span></a> <a href="https://write.as/bs2facdev/tag:%E3%82%A2%E3%83%B3%E3%82%B1%E3%83%BC%E3%83%88" class="hashtag"><span>#</span><span class="p-category">アンケート</span></a> <a href="https://write.as/bs2facdev/tag:%E3%83%87%E3%83%BC%E3%82%BF%E8%A6%96%E8%A6%9A%E5%8C%96" class="hashtag"><span>#</span><span class="p-category">データ視覚化</span></a></p>
]]></content:encoded>
      <guid>https://write.as/bs2facdev/racket-plots-to-browser-page</guid>
      <pubDate>Fri, 22 Mar 2019 12:27:54 +0000</pubDate>
    </item>
    <item>
      <title>Racket lines and point-labels instead of bar-charts</title>
      <link>https://write.as/bs2facdev/racket-lines-and-point-labels-instead-of-bar-charts?pk_campaign=rss-feed</link>
      <description>&lt;![CDATA[This sort of visualization may let me replace bar charts. The panel or facet approach to interleaved discrete histograms might be good for on-screen browsing, but this sort of plot might be easier on the printer and ink supply. &#xA;&#xA;Discussion in Diaspora post comments provides motivation to explore more code and presentation. (fn:1~&#xA;&#xA;Now I have to see about getting these separate images aligned into one eye-span for analytical viewing. &#xA;&#xA; https://snap.as/bsmall2/racket-plot-1/jSH8sgR&#xA; (fn:1) Diaspora post  and discussion in comments&#xA;&#xA;code&#xA;!--more--&#xA;lang racket&#xA;&#xA;(current-directory &#34;FD201801&#34;)&#xA;(current-directory-for-user &#34;FD201801&#34;)&#xA;&#xA;(require plot) ;; discrete-histogram, stacked-histogram etc&#xA;(require plot/utils) ;; -  plot-label&#xA;&#xA;;; Questions Symbols&#xA;(define quest-symbs &#39;(出席 発言 取組 聞取 資料 時刻 反応 熱意 理解 役立 満足))&#xA;&#xA;;; データを入力し直すところ&#xA;(define ind-als ;;教員の連帯リスト associative list&#xA;  &#39;((nme (教員 TCR スモール 教養))&#xA;    (smr (2018 1 H30 Z)) ;; 学期 SeMesteR&#xA;    (cls (1 84))         ;; 授業、教室 CLasS&#xA;    (dta ((62 13 9 0 0)   ;; データ、DaTA&#xA;&#x9; (19 24 28 6 6)&#xA;&#x9; (23 24 27 6 4)&#xA;&#x9; (53 22 9 0 0)&#xA;&#x9; (35 29 19 0 1)&#xA;&#x9; (64 12 7 1 0)&#xA;&#x9; (54 19 10 1 0)&#xA;&#x9; (69 9 6 0 0)&#xA;&#x9; (34 28 16 4 1)&#xA;&#x9; (43 25 12 2 1)&#xA;&#x9; (35 25 20 2 1)))))&#xA;&#xA;(define dep-als ;;学科 associative list&#xA;  &#39;((nme (学科 DPT 教養 大学))&#xA;    (smr (2018 1 H30 Z))&#xA;    (cls (7 269))&#xA;    (dta ((202 41 26 0 0)&#xA;    (62 68 99 22 17)&#xA;    (72 74 98 14 11)&#xA;    (144 67 41 9 8)&#xA;    (111 78 55 13 10)&#xA;    (171 60 28 5 4)&#xA;    (140 65 46 10 8)&#xA;    (165 62 27 9 6)&#xA;    (96 98 51 14 8)&#xA;    (119 76 56 8 8)&#xA;    (109 79 60 9 10)))))&#xA;&#xA;(define uni-als ;;大学&#xA;  &#39;((nme (大学 UVY 南九州 学園))&#xA;    (smr (2018 1 H30 Z))&#xA;    (cls (59 2452))&#xA;    (dta ((1738 472 206 23 8)&#xA;     (495 549 923 195 283)&#xA;     (713 765 736 162 65)&#xA;     (1400 628 296 86 35)&#xA;     (1264 630 384 110 55)&#xA;     (1795 446 166 25 13)&#xA;     (1378 654 317 59 38)&#xA;     (1573 588 230 33 20)&#xA;     (976 886 438 99 42)&#xA;     (1411 684 289 33 24)&#xA;     (1217 740 388 58 38)))))&#xA;&#xA;;; inspired by &#34;Racket for Data Science&#34; code&#xA;;;   by Nicholas M. Van Horn n3mo&#39;s &#xA;(define als-ref&#xA;  (lambda (idx als)&#xA;    (let ((tmp (assv idx als)))&#xA;      (if tmp (cadr tmp) #f))))&#xA;&#xA;(define counts-  percents&#xA;  (lambda (lon) ;; list of numbers&#xA;    (let ((total (apply + lon)))&#xA;      (map (lambda (count)&#xA;&#x9;     ( (/ count total) 100.0))&#xA;&#x9;   lon))))&#xA;&#xA;(define pnt-w-lbl&#xA;  (lambda (x n l)&#xA;    (point-label (vector x n) l #:anchor &#39;bottom)))&#xA;&#xA;(define vline-to-y&#xA;  (lambda (x y)&#xA;    (lines (map vector (list x x) (list 0 y)))))&#xA;&#xA;(define lines-percents-labels-counts&#xA;  (lambda (lon)&#xA;    (let ((pcnts (counts-  percents lon))&#xA;&#x9;  (lvels &#39;(5 4 3 2 1))&#xA;&#x9;  (tot-lab (-  plot-label (apply + lon))))&#xA;      (append ;; need a flat list for plot&#xA;       (map (lambda (l p) ;; level percent&#xA;&#x9;      (vline-to-y l p))&#xA;&#x9;    lvels pcnts)&#xA;       (map (lambda (x n l) ;; xResponse level nNumber point lLabel&#xA;&#x9;      (pnt-w-lbl x n l))&#xA;&#x9;    lvels pcnts (map (lambda (s) (string-append s &#34;/&#34; tot-lab))&#xA;&#x9;&#x9;&#x9;     (map -  plot-label lon)))))))&#xA;&#xA;;; get data ready for lines-percents-labels-counts&#xA;(define dta-  Qss-Als&#xA;  (lambda (Qss Als) ;; Question Symbols, A-list&#xA;    (map list Qss (als-ref &#39;dta Als))))&#xA;&#xA;(define plot-bod-als-to-percentlines-countlabels&#xA;  (lambda (BodAls  Qsyms)&#xA;    (let ((QR-als (dta-  Qss-Als Qsyms BodAls))&#xA;&#x9;   (bod (-  plot-label (car (als-ref &#39;nme BodAls)))))&#xA;      (define lines-percents-titled&#xA;&#x9;(lambda (QR)&#xA;&#x9;  (let ((ttl (string-append bod &#34;:&#34; (-  plot-label (car QR))))&#xA;&#x9;&#x9; (fle-name (string-append ttl (-  plot-label (car (als-ref &#39;smr BodAls))) &#34;0&#34; (-  plot-label (cadr (als-ref &#39;smr BodAls))) &#34;.png&#34;)))&#xA;&#x9;    (plot (lines-percents-labels-counts (cadr QR))&#xA;&#x9;&#x9;#:x-min .2 #:y-max 100 &#xA;&#x9;&#x9;#:x-max 5.8 #:height 250&#xA;&#x9;&#x9;#:width 400 #:y-label &#34;percent&#34;&#xA;&#x9;&#x9;#:x-label &#34;levels&#34;&#xA;&#x9;&#x9;#:title ttl&#xA;&#x9;&#x9;#:out-file fle-name&#xA; &#x9;&#x9;#:out-kind &#39;png))))&#xA;      (map lines-percents-titled QR-als))))&#xA;&#xA;;;; Working!!&#x9;&#x9;&#xA;(parameterize ((plot-tick-size 3)&#xA;                (plot-x-far-axis? #f)&#xA;                (plot-y-far-axis? #f))&#xA;  (plot-bod-als-to-percentlines-countlabels uni-als quest-symbs))&#xA;&#xA;#Scheme #Racket #FS4FT #FS4FD #facdev #FacultyDevelopment #DataVisualizatoin #アンケート #データ視覚化]]&gt;</description>
      <content:encoded><![CDATA[<p>This sort of visualization may let me replace bar charts. The panel or facet approach to interleaved discrete histograms might be good for on-screen browsing, but this sort of plot might be easier on the printer and ink supply.</p>

<p>Discussion in Diaspora* post comments provides motivation to explore more code and presentation. (fn:1~</p>

<p><img src="https://i.snap.as/50WEYKn.image" alt=""/></p>

<p>Now I have to see about getting these separate images aligned into one eye-span for analytical viewing.</p>

<p><img src="https://i.snap.as/FcMNL0h.jpg" alt=""/></p>
<ul><li><a href="https://snap.as/bsmall2/racket-plot-1/jSH8sgR">https://snap.as/bsmall2/racket-plot-1/jSH8sgR</a></li>
<li>(fn:1) <a href="https://ruhrspora.de/posts/3a5627502c8c013743ae005056009f8c">Diaspora* post</a>  and discussion in comments</li></ul>

<h1 id="code">code</h1>



<pre><code>#lang racket

(current-directory &#34;FD201801&#34;)
(current-directory-for-user &#34;FD201801&#34;)

(require plot) ;; discrete-histogram, stacked-histogram etc
(require plot/utils) ;; -&gt;plot-label

;; Questions Symbols
(define quest-symbs &#39;(出席 発言 取組 聞取 資料 時刻 反応 熱意 理解 役立 満足))


;; データを入力し直すところ
(define ind-als ;;教員の連帯リスト associative list
  &#39;((nme (教員 TCR スモール 教養))
    (smr (2018 1 H30 Z)) ;; 学期 SeMesteR
    (cls (1 84))         ;; 授業、教室 CLasS
    (dta ((62 13 9 0 0)   ;; データ、DaTA
	 (19 24 28 6 6)
	 (23 24 27 6 4)
	 (53 22 9 0 0)
	 (35 29 19 0 1)
	 (64 12 7 1 0)
	 (54 19 10 1 0)
	 (69 9 6 0 0)
	 (34 28 16 4 1)
	 (43 25 12 2 1)
	 (35 25 20 2 1)))))

(define dep-als ;;学科 associative list
  &#39;((nme (学科 DPT 教養 大学))
    (smr (2018 1 H30 Z))
    (cls (7 269))
    (dta ((202 41 26 0 0)
    (62 68 99 22 17)
    (72 74 98 14 11)
    (144 67 41 9 8)
    (111 78 55 13 10)
    (171 60 28 5 4)
    (140 65 46 10 8)
    (165 62 27 9 6)
    (96 98 51 14 8)
    (119 76 56 8 8)
    (109 79 60 9 10)))))

(define uni-als ;;大学
  &#39;((nme (大学 UVY 南九州 学園))
    (smr (2018 1 H30 Z))
    (cls (59 2452))
    (dta ((1738 472 206 23 8)
     (495 549 923 195 283)
     (713 765 736 162 65)
     (1400 628 296 86 35)
     (1264 630 384 110 55)
     (1795 446 166 25 13)
     (1378 654 317 59 38)
     (1573 588 230 33 20)
     (976 886 438 99 42)
     (1411 684 289 33 24)
     (1217 740 388 58 38)))))

;; inspired by &#34;Racket for Data Science&#34; code
;;   by Nicholas M. Van Horn n3mo&#39;s 
(define als-ref
  (lambda (idx als)
    (let ((tmp (assv idx als)))
      (if tmp (cadr tmp) #f))))


(define counts-&gt;percents
  (lambda (lon) ;; list of numbers
    (let ((total (apply + lon)))
      (map (lambda (count)
	     (* (/ count total) 100.0))
	   lon))))

(define pnt-w-lbl
  (lambda (x n l)
    (point-label (vector x n) l #:anchor &#39;bottom)))

(define vline-to-y
  (lambda (x y)
    (lines (map vector (list x x) (list 0 y)))))

(define lines-percents-labels-counts
  (lambda (lon)
    (let ((pcnts (counts-&gt;percents lon))
	  (lvels &#39;(5 4 3 2 1))
	  (tot-lab (-&gt;plot-label (apply + lon))))
      (append ;; need a flat list for plot
       (map (lambda (l p) ;; level percent
	      (vline-to-y l p))
	    lvels pcnts)
       (map (lambda (x n l) ;; xResponse level nNumber point lLabel
	      (pnt-w-lbl x n l))
	    lvels pcnts (map (lambda (s) (string-append s &#34;/&#34; tot-lab))
			     (map -&gt;plot-label lon)))))))


;; get data ready for lines-percents-labels-counts
(define dta-&gt;Qss-Als
  (lambda (Qss Als) ;; Question Symbols, A-list
    (map list Qss (als-ref &#39;dta Als))))

(define plot-bod-als-to-percentlines-countlabels
  (lambda (BodAls  Qsyms)
    (let ((QR-als (dta-&gt;Qss-Als Qsyms BodAls))
	   (bod (-&gt;plot-label (car (als-ref &#39;nme BodAls)))))
      (define lines-percents-titled
	(lambda (QR)
	  (let* ((ttl (string-append bod &#34;:&#34; (-&gt;plot-label (car QR))))
		 (fle-name (string-append ttl (-&gt;plot-label (car (als-ref &#39;smr BodAls))) &#34;0&#34; (-&gt;plot-label (cadr (als-ref &#39;smr BodAls))) &#34;.png&#34;)))
	    (plot (lines-percents-labels-counts (cadr QR))
		#:x-min .2 #:y-max 100 
		#:x-max 5.8 #:height 250
		#:width 400 #:y-label &#34;percent&#34;
		#:x-label &#34;levels&#34;
		#:title ttl
		#:out-file fle-name
 		#:out-kind &#39;png))))
      (map lines-percents-titled QR-als))))

;;; Working!!		
(parameterize ((plot-tick-size 3)
                (plot-x-far-axis? #f)
                (plot-y-far-axis? #f))
  (plot-bod-als-to-percentlines-countlabels uni-als quest-symbs))

</code></pre>

<p><a href="https://write.as/bs2facdev/tag:Scheme" class="hashtag"><span>#</span><span class="p-category">Scheme</span></a> <a href="https://write.as/bs2facdev/tag:Racket" class="hashtag"><span>#</span><span class="p-category">Racket</span></a> <a href="https://write.as/bs2facdev/tag:FS4FT" class="hashtag"><span>#</span><span class="p-category">FS4FT</span></a> <a href="https://write.as/bs2facdev/tag:FS4FD" class="hashtag"><span>#</span><span class="p-category">FS4FD</span></a> <a href="https://write.as/bs2facdev/tag:facdev" class="hashtag"><span>#</span><span class="p-category">facdev</span></a> <a href="https://write.as/bs2facdev/tag:FacultyDevelopment" class="hashtag"><span>#</span><span class="p-category">FacultyDevelopment</span></a> <a href="https://write.as/bs2facdev/tag:DataVisualizatoin" class="hashtag"><span>#</span><span class="p-category">DataVisualizatoin</span></a> <a href="https://write.as/bs2facdev/tag:%E3%82%A2%E3%83%B3%E3%82%B1%E3%83%BC%E3%83%88" class="hashtag"><span>#</span><span class="p-category">アンケート</span></a> <a href="https://write.as/bs2facdev/tag:%E3%83%87%E3%83%BC%E3%82%BF%E8%A6%96%E8%A6%9A%E5%8C%96" class="hashtag"><span>#</span><span class="p-category">データ視覚化</span></a></p>
]]></content:encoded>
      <guid>https://write.as/bs2facdev/racket-lines-and-point-labels-instead-of-bar-charts</guid>
      <pubDate>Wed, 20 Mar 2019 16:12:49 +0000</pubDate>
    </item>
    <item>
      <title>Racket plot: lines for percents, labels for counts</title>
      <link>https://write.as/bs2facdev/racket-plot-lines-for-percents-labels-for-counts?pk_campaign=rss-feed</link>
      <description>&lt;![CDATA[I was feeling overwhelmed while try to label the bars in interleaved, discrete histogram plots of percentages. So I went back to the basics: lines and points. &#xA;There is probably a straightforward way to montage a series of plots together, but I haven&#39;t found it yet. Maybe series of this sort of plot panel for different results can be helpful if grouped and aligned on an .html page and seen in a browser. &#xA;&#xA;Racket Plot, lines for percents, labels for counts&#xA;&#xA;code&#xA;!--more--&#xA;lang racket&#xA;&#xA;(require plot) ;; discrete-histogram, stacked-histogram etc&#xA;(require plot/utils) ;; -  plot-label&#xA;&#xA;(define listsmpl &#39;(62 13 9 0 0))&#xA;&#xA;(define counts-  percents&#xA;  (lambda (lon) ;; list of numbers&#xA;    (let ((total (apply + lon)))&#xA;      (map (lambda (count)&#xA;&#x9;     (* (/ count total) 100.0))&#xA;&#x9;   lon))))&#xA;&#xA;(define pnt-w-lbl&#xA;  (lambda (x n l)&#xA;    (point-label (vector x n) l #:anchor &#39;bottom)))&#xA;&#xA;(define vline-to-y&#xA;  (lambda (x y)&#xA;    (lines (map vector (list x x) (list 0 y)))))&#xA;&#xA;(define lines-percents-labels-counts&#xA;  (lambda (lon)&#xA;    (let ((pcnts (counts-  percents lon))&#xA;&#x9;  (lvels &#39;(5 4 3 2 1))&#xA;&#x9;  (tot-lab (-  plot-label (apply + lon))))&#xA;      (append ;; need a flat list for plot&#xA;       (map (lambda (l p) ;; level percent&#xA;&#x9;      (vline-to-y l p))&#xA;&#x9;    lvels pcnts)&#xA;       (map (lambda (x n l) ;; xResponse level nNumber point lLabel&#xA;&#x9;      (pnt-w-lbl x n l))&#xA;&#x9;    lvels pcnts (map (lambda (s) (string-append s &#34;/&#34; tot-lab))&#xA;&#x9;&#x9;&#x9;     (map -  plot-label lon)))))))&#xA;&#xA;(plot (lines-percents-labels-counts listsmpl)&#xA;     #:y-max 100 #:x-min .2 #:x-max 5.8&#xA;      #:width 300 #:height 250&#xA;     #:x-label &#34;levels&#34;  #:y-label &#34;percent&#34;)&#xA;#Scheme #Racket #FS4FT #FS4FD #facdev #FacultyDevelopment #DataVisualizatoin #アンケート #データ視覚化 ]]&gt;</description>
      <content:encoded><![CDATA[<p>I was feeling overwhelmed while try to label the bars in interleaved, discrete histogram plots of percentages. So I went back to the basics: lines and points.
There is probably a straightforward way to montage a series of plots together, but I haven&#39;t found it yet. Maybe series of this sort of plot panel for different results can be helpful if grouped and aligned on an .html page and seen in a browser.</p>

<p><img src="https://i.snap.as/kS8mMXQ.png" alt="Racket Plot, lines for percents, labels for counts" title="Racket Plot, lines for percents, labels for counts"/></p>

<h3 id="code">code</h3>



<pre><code>#lang racket

(require plot) ;; discrete-histogram, stacked-histogram etc
(require plot/utils) ;; -&gt;plot-label

(define listsmpl &#39;(62 13 9 0 0))

(define counts-&gt;percents
  (lambda (lon) ;; list of numbers
    (let ((total (apply + lon)))
      (map (lambda (count)
	     (* (/ count total) 100.0))
	   lon))))

(define pnt-w-lbl
  (lambda (x n l)
    (point-label (vector x n) l #:anchor &#39;bottom)))

(define vline-to-y
  (lambda (x y)
    (lines (map vector (list x x) (list 0 y)))))

(define lines-percents-labels-counts
  (lambda (lon)
    (let ((pcnts (counts-&gt;percents lon))
	  (lvels &#39;(5 4 3 2 1))
	  (tot-lab (-&gt;plot-label (apply + lon))))
      (append ;; need a flat list for plot
       (map (lambda (l p) ;; level percent
	      (vline-to-y l p))
	    lvels pcnts)
       (map (lambda (x n l) ;; xResponse level nNumber point lLabel
	      (pnt-w-lbl x n l))
	    lvels pcnts (map (lambda (s) (string-append s &#34;/&#34; tot-lab))
			     (map -&gt;plot-label lon)))))))

(plot (lines-percents-labels-counts listsmpl)
     #:y-max 100 #:x-min .2 #:x-max 5.8
      #:width 300 #:height 250
     #:x-label &#34;levels&#34;  #:y-label &#34;percent&#34;)
</code></pre>

<p><a href="https://write.as/bs2facdev/tag:Scheme" class="hashtag"><span>#</span><span class="p-category">Scheme</span></a> <a href="https://write.as/bs2facdev/tag:Racket" class="hashtag"><span>#</span><span class="p-category">Racket</span></a> <a href="https://write.as/bs2facdev/tag:FS4FT" class="hashtag"><span>#</span><span class="p-category">FS4FT</span></a> <a href="https://write.as/bs2facdev/tag:FS4FD" class="hashtag"><span>#</span><span class="p-category">FS4FD</span></a> <a href="https://write.as/bs2facdev/tag:facdev" class="hashtag"><span>#</span><span class="p-category">facdev</span></a> <a href="https://write.as/bs2facdev/tag:FacultyDevelopment" class="hashtag"><span>#</span><span class="p-category">FacultyDevelopment</span></a> <a href="https://write.as/bs2facdev/tag:DataVisualizatoin" class="hashtag"><span>#</span><span class="p-category">DataVisualizatoin</span></a> <a href="https://write.as/bs2facdev/tag:%E3%82%A2%E3%83%B3%E3%82%B1%E3%83%BC%E3%83%88" class="hashtag"><span>#</span><span class="p-category">アンケート</span></a> <a href="https://write.as/bs2facdev/tag:%E3%83%87%E3%83%BC%E3%82%BF%E8%A6%96%E8%A6%9A%E5%8C%96" class="hashtag"><span>#</span><span class="p-category">データ視覚化</span></a></p>
]]></content:encoded>
      <guid>https://write.as/bs2facdev/racket-plot-lines-for-percents-labels-for-counts</guid>
      <pubDate>Wed, 20 Mar 2019 14:06:40 +0000</pubDate>
    </item>
    <item>
      <title>Racket: Plot interleaved discrete-histograms</title>
      <link>https://write.as/bs2facdev/racket-plot-interleaved-discrete-histograms?pk_campaign=rss-feed</link>
      <description>&lt;![CDATA[DrRacket is great for checking code developed with Emacs geiser-mode. After pasting the text from and Emacs buffer and clicking the &#34;Run&#34; button, DrRacket reminds me of all the definitions from previous scripts and REPL experiments that never made it into the file. &#xA;&#xA;DrRacket Code and Plots for Interleaved Discrete-Histograms&#xA;&#xA;This code is still clumsy, the process isn&#39;t clear enough in my mind for elegant solutions. But working through the process is great for learning. This may be a way to re-discover the faceting that R/ggplot2 makes possible. I think this is the best way to get a feel for how an individual teachers results are situated in relation to the groups: the individual&#39;s department and school.&#xA;!--more--&#xA;&#xA;It would be great to get Racket-competent students and citizens with questions to explore. We could implement the Questionnaires and their Visualization ourselves, with good questions it might be possible to continue the work of Ignacio Martin-Baro and Ignacio Ellacuria &#34;Towards a Society that Serves its People&#34;. In the meantime these Faculty Development Questionnaires provide data for training in computer languages, data transformations, and information designs.&#xA;&#xA;Interleaved Discrete Histogram: enthused facet&#xA;&#xA;Although DrRacket is great, Emacs keybindings for going to the start and end of lines, for switching buffers and windows, for going to the head or tail of a buffer, and the keyboard macros just make development smoother. &#xA;&#xA;Racket code development in Emacs with Geiser&#xA;&#xA;It&#39;s always a shock to press [Ctrl]-[e] and have a DrRacket panel disappear. But DrRacket is fun, the arrows that show you where definitions come from....&#xA;&#xA;code&#xA;lang racket&#xA;&#xA; (current-directory &#34;FD201801&#34;)&#xA; (current-directory-for-user &#34;FD201801&#34;)&#xA;&#xA;;;(require racket/format) ;; for ~r #:precision&#xA;;;(require plot/utils) ;; linear-seq exact-  inexact&#xA;(require plot) ;; discrete-histogram, stacked-histogram etc&#xA;;; (require scribble/html/html) ;; to view png files in browser&#xA;;; (require scribble/html) ;; output-xml to make .html page for browser&#xA;&#xA;;; (define RsEng (map (lambda (l) (list (car l) (cadddr l))) responses))&#xA;;; (define QsEng (map cadr questions-English))&#xA;&#xA;(define quest-symbs &#39;(出席 発言 取組 聞取 資料 時刻 反応 熱意 理解 役立 満足))&#xA;&#xA;(define ind-als ;;教員の連帯リスト associative list&#xA;  &#39;((nme (教員 TCR スモール 教養))&#xA;    (smr (2018 1 H30 Z)) ;; 学期 SeMesteR&#xA;    (cls (1 84))         ;; 授業、教室 CLasS&#xA;    (dta ((62 13 9 0 0)   ;; データ、DaTA&#xA;&#x9; (19 24 28 6 6)&#xA;&#x9; (23 24 27 6 4)&#xA;&#x9; (53 22 9 0 0)&#xA;&#x9; (35 29 19 0 1)&#xA;&#x9; (64 12 7 1 0)&#xA;&#x9; (54 19 10 1 0)&#xA;&#x9; (69 9 6 0 0)&#xA;&#x9; (34 28 16 4 1)&#xA;&#x9; (43 25 12 2 1)&#xA;&#x9; (35 25 20 2 1)))))&#xA;&#xA;(define dep-als ;;学科 associative list&#xA;  &#39;((nme (学科 DPT 教養 大学))&#xA;    (smr (2018 1 H30 Z))&#xA;    (cls (7 269))&#xA;    (dta ((202 41 26 0 0)&#xA;    (62 68 99 22 17)&#xA;    (72 74 98 14 11)&#xA;    (144 67 41 9 8)&#xA;    (111 78 55 13 10)&#xA;    (171 60 28 5 4)&#xA;    (140 65 46 10 8)&#xA;    (165 62 27 9 6)&#xA;    (96 98 51 14 8)&#xA;    (119 76 56 8 8)&#xA;    (109 79 60 9 10)))))&#xA;&#xA;(define uni-als ;;大学&#xA;  &#39;((nme (大学 UVY 南九州 学園))&#xA;    (smr (2018 1 H30 Z))&#xA;    (cls (59 2452))&#xA;    (dta ((1738 472 206 23 8)&#xA;     (495 549 923 195 283)&#xA;     (713 765 736 162 65)&#xA;     (1400 628 296 86 35)&#xA;     (1264 630 384 110 55)&#xA;     (1795 446 166 25 13)&#xA;     (1378 654 317 59 38)&#xA;     (1573 588 230 33 20)&#xA;     (976 886 438 99 42)&#xA;     (1411 684 289 33 24)&#xA;     (1217 740 388 58 38)))))&#xA;&#xA;(define als-ref&#xA;  (lambda (idx als)&#xA;    (let ((tmp (assv idx als)))&#xA;      (if tmp (cadr tmp) #f))))&#xA;&#xA;(define count-  percent&#xA;  (lambda (lst) ;; list of lists&#xA;    (let ((total (apply + lst)))&#xA;      (map (lambda (cnt)&#xA;&#x9;     (* (/ cnt total) 100.0))&#xA;&#x9;   lst))))&#xA;;; might need to truncate decimal places for labels later&#xA;;; in plot/utils  (real-  decimal-string num 2) (r-  d-s num min)&#xA;(define vctrz-rspns-prcnt&#xA;  (lambda (lst)&#xA;    (map vector &#39;(5 4 3 2 1) (count-  percent lst))))&#xA;(define labl-from-alst&#xA;  (lambda (als)&#xA;    (format &#34;~a~a&#34; (car (als-ref &#39;nme als)) (cadr (als-ref &#39;nme als)))))&#xA;&#xA;(define intrleav-3-dsct-hstm-1&#xA;  (lambda (l1 l2 l3)&#xA;    (list&#xA;     (discrete-histogram&#xA;      l1&#xA;      #:skip 3.5 #:x-min 0&#xA;      #:label &#34;教員TCR&#34;) ;; 教員&#xA;     (discrete-histogram&#xA;      l2&#xA;      #:skip 3.5 #:x-min 1  ;; 学科&#xA;      #:label &#34;学科DEP&#34; #:color 2 #:line-color 2)&#xA;     (discrete-histogram&#xA;      l3&#xA;      #:skip 3.5 #:x-min 2  ;; 大学&#xA;      #:label &#34;大学UVY&#34; #:color 4 #:line-color 4))))&#xA;&#xA;(map (lambda (l1 l2 l3 Q)&#xA;       (plot (intrleav-3-dsct-hstm-1&#xA;&#x9;      (vctrz-rspns-prcnt l1)&#xA;&#x9;      (vctrz-rspns-prcnt l2)&#xA;&#x9;      (vctrz-rspns-prcnt l3))&#xA;&#x9;     #:title (symbol-  string Q) #:x-label &#34;Response Level&#34;&#xA;             #:y-label &#34;Percent&#34; #:y-max 100&#xA;             #:legend-anchor &#39;top-right&#xA;             #:height 300))&#xA;     (als-ref &#39;dta ind-als)&#xA;     (als-ref &#39;dta dep-als)&#xA;     (als-ref &#39;dta uni-als)&#xA;     quest-symbs)&#xA;;; need a function that will take alists and plot to file&#xA;&#xA;(define plot-3-alsts-intrleaved-to-file&#xA;  (lambda (als1 als2 als3 Qsymbs)&#xA;    (map (lambda (l1 l2 l3 Q)&#xA;&#x9;   (plot-file (intrleav-3-dsct-hstm-1&#xA;&#x9;&#x9;       (vctrz-rspns-prcnt l1)&#xA;&#x9;&#x9;       (vctrz-rspns-prcnt l2)&#xA;&#x9;&#x9;       (vctrz-rspns-prcnt l3))&#xA;&#x9;&#x9;      #:title (symbol-  string Q)&#xA;&#x9;&#x9;      #:x-label &#34;Response Value&#34;&#xA;&#x9;&#x9;      #:y-label &#34;Percent%&#34;&#xA;&#x9;&#x9;      #:y-max 100&#xA;&#x9;&#x9;      #:legend-anchor &#39;top-right&#xA;                      #:height 300&#xA;&#x9;&#x9;      (format &#34;~a~a~a~a.png&#34; (symbol-  string Q)&#xA;&#x9;&#x9;&#x9;       (car (als-ref &#39;smr als1))&#xA;&#x9;&#x9;&#x9;       0&#xA;&#x9;&#x9;&#x9;       (cadr (als-ref &#39;smr als1)))&#xA;&#x9;&#x9;      &#39;png))&#xA;&#x9; (als-ref &#39;dta als1)&#xA;&#x9; (als-ref &#39;dta als2)&#xA;&#x9; (als-ref &#39;dta als3)&#xA;&#x9; Qsymbs)))&#xA;&#xA;(plot-3-alsts-intrleaved-to-file ind-als dep-als uni-als quest-symbs)&#xA;&#xA;#Scheme #Racket #FS4FT #FS4FD #facdev #FacultyDevelopment #DataVisualizatoin #アンケート #データ視覚化 ]]&gt;</description>
      <content:encoded><![CDATA[<p>DrRacket is great for checking code developed with Emacs geiser-mode. After pasting the text from and Emacs buffer and clicking the “Run” button, DrRacket reminds me of all the definitions from previous scripts and REPL experiments that never made it into the file.</p>

<p><img src="https://i.snap.as/rBgcInV.png" alt="DrRacket Code and Plots for Interleaved Discrete-Histograms" title="DrRacket Code and Plots for Interleaved Discrete-Histograms"/></p>

<p>This code is still clumsy, the process isn&#39;t clear enough in my mind for elegant solutions. But working through the process is great for learning. This may be a way to re-discover the faceting that R/ggplot2 makes possible. I think this is the best way to get a feel for how an individual teachers results are situated in relation to the groups: the individual&#39;s department and school.
</p>

<p>It would be great to get Racket-competent students and citizens with questions to explore. We could implement the Questionnaires and their Visualization ourselves, with good questions it might be possible to continue the work of Ignacio Martin-Baro and Ignacio Ellacuria “Towards a Society that Serves its People”. In the meantime these Faculty Development Questionnaires provide data for training in computer languages, data transformations, and information designs.</p>

<p><img src="https://i.snap.as/fcMmWjb.image" alt="Interleaved Discrete Histogram: enthused facet" title="Interleaved Discrete Histogram: enthused facet"/></p>

<p>Although DrRacket is great, Emacs keybindings for going to the start and end of lines, for switching buffers and windows, for going to the head or tail of a buffer, and the keyboard macros just make development smoother.</p>

<p><img src="https://i.snap.as/wZil452.png" alt="Racket code development in Emacs with Geiser" title="Racket code development in Emacs with Geiser"/></p>

<p>It&#39;s always a shock to press [Ctrl]-[e] and have a DrRacket panel disappear. But DrRacket is fun, the arrows that show you where definitions come from....</p>

<h3 id="code">code</h3>

<pre><code>#lang racket

 (current-directory &#34;FD201801&#34;)
 (current-directory-for-user &#34;FD201801&#34;)

;;(require racket/format) ;; for ~r #:precision
;;(require plot/utils) ;; linear-seq exact-&gt;inexact
(require plot) ;; discrete-histogram, stacked-histogram etc
;; (require scribble/html/html) ;; to view png files in browser
;; (require scribble/html) ;; output-xml to make .html page for browser

;; (define RsEng (map (lambda (l) (list (car l) (cadddr l))) responses))
;; (define QsEng (map cadr questions-English))

(define quest-symbs &#39;(出席 発言 取組 聞取 資料 時刻 反応 熱意 理解 役立 満足))

(define ind-als ;;教員の連帯リスト associative list
  &#39;((nme (教員 TCR スモール 教養))
    (smr (2018 1 H30 Z)) ;; 学期 SeMesteR
    (cls (1 84))         ;; 授業、教室 CLasS
    (dta ((62 13 9 0 0)   ;; データ、DaTA
	 (19 24 28 6 6)
	 (23 24 27 6 4)
	 (53 22 9 0 0)
	 (35 29 19 0 1)
	 (64 12 7 1 0)
	 (54 19 10 1 0)
	 (69 9 6 0 0)
	 (34 28 16 4 1)
	 (43 25 12 2 1)
	 (35 25 20 2 1)))))

(define dep-als ;;学科 associative list
  &#39;((nme (学科 DPT 教養 大学))
    (smr (2018 1 H30 Z))
    (cls (7 269))
    (dta ((202 41 26 0 0)
    (62 68 99 22 17)
    (72 74 98 14 11)
    (144 67 41 9 8)
    (111 78 55 13 10)
    (171 60 28 5 4)
    (140 65 46 10 8)
    (165 62 27 9 6)
    (96 98 51 14 8)
    (119 76 56 8 8)
    (109 79 60 9 10)))))

(define uni-als ;;大学
  &#39;((nme (大学 UVY 南九州 学園))
    (smr (2018 1 H30 Z))
    (cls (59 2452))
    (dta ((1738 472 206 23 8)
     (495 549 923 195 283)
     (713 765 736 162 65)
     (1400 628 296 86 35)
     (1264 630 384 110 55)
     (1795 446 166 25 13)
     (1378 654 317 59 38)
     (1573 588 230 33 20)
     (976 886 438 99 42)
     (1411 684 289 33 24)
     (1217 740 388 58 38)))))

(define als-ref
  (lambda (idx als)
    (let ((tmp (assv idx als)))
      (if tmp (cadr tmp) #f))))

(define count-&gt;percent
  (lambda (lst) ;; list of lists
    (let ((total (apply + lst)))
      (map (lambda (cnt)
	     (* (/ cnt total) 100.0))
	   lst))))
;; might need to truncate decimal places for labels later
;; in plot/utils  (real-&gt;decimal-string num 2) (r-&gt;d-s num min)
(define vctrz-rspns-prcnt
  (lambda (lst)
    (map vector &#39;(5 4 3 2 1) (count-&gt;percent lst))))
(define labl-from-alst
  (lambda (als)
    (format &#34;~a~a&#34; (car (als-ref &#39;nme als)) (cadr (als-ref &#39;nme als)))))

(define intrleav-3-dsct-hstm-1
  (lambda (l1 l2 l3)
    (list
     (discrete-histogram
      l1
      #:skip 3.5 #:x-min 0
      #:label &#34;教員TCR&#34;) ;; 教員
     (discrete-histogram
      l2
      #:skip 3.5 #:x-min 1  ;; 学科
      #:label &#34;学科DEP&#34; #:color 2 #:line-color 2)
     (discrete-histogram
      l3
      #:skip 3.5 #:x-min 2  ;; 大学
      #:label &#34;大学UVY&#34; #:color 4 #:line-color 4))))

(map (lambda (l1 l2 l3 Q)
       (plot (intrleav-3-dsct-hstm-1
	      (vctrz-rspns-prcnt l1)
	      (vctrz-rspns-prcnt l2)
	      (vctrz-rspns-prcnt l3))
	     #:title (symbol-&gt;string Q) #:x-label &#34;Response Level&#34;
             #:y-label &#34;Percent&#34; #:y-max 100
             #:legend-anchor &#39;top-right
             #:height 300))
     (als-ref &#39;dta ind-als)
     (als-ref &#39;dta dep-als)
     (als-ref &#39;dta uni-als)
     quest-symbs)
;; need a function that will take alists and plot to file

(define plot-3-alsts-intrleaved-to-file
  (lambda (als1 als2 als3 Qsymbs)
    (map (lambda (l1 l2 l3 Q)
	   (plot-file (intrleav-3-dsct-hstm-1
		       (vctrz-rspns-prcnt l1)
		       (vctrz-rspns-prcnt l2)
		       (vctrz-rspns-prcnt l3))
		      #:title (symbol-&gt;string Q)
		      #:x-label &#34;Response Value&#34;
		      #:y-label &#34;Percent%&#34;
		      #:y-max 100
		      #:legend-anchor &#39;top-right
                      #:height 300
		      (format &#34;~a~a~a~a.png&#34; (symbol-&gt;string Q)
			       (car (als-ref &#39;smr als1))
			       0
			       (cadr (als-ref &#39;smr als1)))
		      &#39;png))
	 (als-ref &#39;dta als1)
	 (als-ref &#39;dta als2)
	 (als-ref &#39;dta als3)
	 Qsymbs)))

(plot-3-alsts-intrleaved-to-file ind-als dep-als uni-als quest-symbs)

</code></pre>

<p><a href="https://write.as/bs2facdev/tag:Scheme" class="hashtag"><span>#</span><span class="p-category">Scheme</span></a> <a href="https://write.as/bs2facdev/tag:Racket" class="hashtag"><span>#</span><span class="p-category">Racket</span></a> <a href="https://write.as/bs2facdev/tag:FS4FT" class="hashtag"><span>#</span><span class="p-category">FS4FT</span></a> <a href="https://write.as/bs2facdev/tag:FS4FD" class="hashtag"><span>#</span><span class="p-category">FS4FD</span></a> <a href="https://write.as/bs2facdev/tag:facdev" class="hashtag"><span>#</span><span class="p-category">facdev</span></a> <a href="https://write.as/bs2facdev/tag:FacultyDevelopment" class="hashtag"><span>#</span><span class="p-category">FacultyDevelopment</span></a> <a href="https://write.as/bs2facdev/tag:DataVisualizatoin" class="hashtag"><span>#</span><span class="p-category">DataVisualizatoin</span></a> <a href="https://write.as/bs2facdev/tag:%E3%82%A2%E3%83%B3%E3%82%B1%E3%83%BC%E3%83%88" class="hashtag"><span>#</span><span class="p-category">アンケート</span></a> <a href="https://write.as/bs2facdev/tag:%E3%83%87%E3%83%BC%E3%82%BF%E8%A6%96%E8%A6%9A%E5%8C%96" class="hashtag"><span>#</span><span class="p-category">データ視覚化</span></a></p>
]]></content:encoded>
      <guid>https://write.as/bs2facdev/racket-plot-interleaved-discrete-histograms</guid>
      <pubDate>Tue, 19 Mar 2019 15:31:33 +0000</pubDate>
    </item>
    <item>
      <title>Racket plot stacked-histograms, show in browser page</title>
      <link>https://write.as/bs2facdev/racket-plot-stacked-histograms-show-in-browser-page?pk_campaign=rss-feed</link>
      <description>&lt;![CDATA[Racket plot and scribble/html with stacked-histograms and output-xml are working well. It was fun to play with plot keywords and think about printing the data visualizations, but for quick comparisons in the browser the defaults seem better. &#xA;&#xA;I imagine DrRacket will make the code below work with a Windows computer too. How would Windows users be able to find their home directory, Racket&#39;s (current-directory) and get their bowser to show &#34;/FD201801/FD-Anketo-Results.html&#34;...  The file-separator slashes are probably different too. But that sort of detail can be overcome when a Windows user shows an interest in testing the code and visualization...&#xA;&#xA;Screenshot of DrRacket with code and plotted images on generated page in browser window&#xA;&#xA;It was good training to work with associative lists, to use two a-lists to generate a new a-list. Using a-lists allows for the generation of useful titles and file names that match the data used for the visualization. &#xA;!--more--&#xA;教員抜き大学の結果：  大学w-o教員&#xA;The image below is a visualization of the university data with one teacher&#39;s results removed.  A teacher&#39;s comment about the difficulty in interpreting result averages without reference to the department averages and the minimum and maximum values prompted the &#34;w-o&#34; data and visualization exercise. &#xA;&#xA;Reading a Japanese book about Gauche Scheme helped me see how important it is to get the data into structures that make the work go smoothly. &#xA;&#xA;code&#xA;&#xA;lang racket&#xA;&#xA;;; Generate Data Visualizations for Questionnaire Results&#xA;;;  let teachers see their results &#xA;;;   see relations to their department and university&#xA;;;  ~/FD201801/FD-Anketo-Results.html&#xA;&#xA;;; 画像ファイル、.htmlページを書き込むフォルダー:directory&#xA;(make-directory* &#34;FD201801&#34;)&#xA;(current-directory &#34;FD201801&#34;)&#xA;(current-directory-for-user &#34;FD201801&#34;)&#xA;&#xA;(require plot) &#xA;(require scribble/html/html) ;; to view png files in browser&#xA;(require scribble/html) ;; output-xml to make .html page for browser&#xA;&#xA;;; データを入力し直すところ&#xA;(define ind-als ;;教員の連帯リスト associative list&#xA;  &#39;((nme (教員 TCR スモール 教養))&#xA;    (smr (2018 1 H30 Z)) ;; 学期 SeMesteR&#xA;    (cls (1 84))         ;; 授業、教室 CLasS&#xA;    (dta ((62 13 9 0 0)   ;; データ、DaTA&#xA;&#x9; (19 24 28 6 6)&#xA;&#x9; (23 24 27 6 4)&#xA;&#x9; (53 22 9 0 0)&#xA;&#x9; (35 29 19 0 1)&#xA;&#x9; (64 12 7 1 0)&#xA;&#x9; (54 19 10 1 0)&#xA;&#x9; (69 9 6 0 0)&#xA;&#x9; (34 28 16 4 1)&#xA;&#x9; (43 25 12 2 1)&#xA;&#x9; (35 25 20 2 1)))))&#xA;&#xA;(define dep-als ;;学科 associative list&#xA;  &#39;((nme (学科 DPT 教養 大学))&#xA;    (smr (2018 1 H30 Z))&#xA;    (cls (7 269))&#xA;    (dta ((202 41 26 0 0)&#xA;    (62 68 99 22 17)&#xA;    (72 74 98 14 11)&#xA;    (144 67 41 9 8)&#xA;    (111 78 55 13 10)&#xA;    (171 60 28 5 4)&#xA;    (140 65 46 10 8)&#xA;    (165 62 27 9 6)&#xA;    (96 98 51 14 8)&#xA;    (119 76 56 8 8)&#xA;    (109 79 60 9 10)))))&#xA;&#xA;(define uni-als ;;大学&#xA;  &#39;((nme (大学 UVY 南九州 学園))&#xA;    (smr (2018 1 H30 Z))&#xA;    (cls (59 2452))&#xA;    (dta ((1738 472 206 23 8)&#xA;     (495 549 923 195 283)&#xA;     (713 765 736 162 65)&#xA;     (1400 628 296 86 35)&#xA;     (1264 630 384 110 55)&#xA;     (1795 446 166 25 13)&#xA;     (1378 654 317 59 38)&#xA;     (1573 588 230 33 20)&#xA;     (976 886 438 99 42)&#xA;     (1411 684 289 33 24)&#xA;     (1217 740 388 58 38)))))&#xA;&#xA;;; Questions Symbols&#xA;(define quest-symbs &#39;(出席 発言 取組 聞取 資料 時刻 反応 熱意 理解 役立 満足))&#xA;&#xA;;; short symbol for Qquestion, Japanese Sentence,  short symbol for Q-type&#xA;(define questions &#39;(&#xA;(出席 &#x9;&#34;私はこの授業によく出席した&#34;                                              学生取組)&#xA;(発言 &#x9;&#34;私は授業内容について質問や発言した&#34;                                      学生取組)&#xA;(取組 &#x9;&#34;私はこの科目に積極的に取り組んだ(予習と復習した)&#34;                      学生取組)&#xA;(聞取 &#x9;&#34;教員の声は聞き取りやすかった。&#34;                                          教員実施)&#xA;(資料 &#x9;&#34;教員の板書（またはPPT・配布資料など）は読みやすかった（見やすかった）&#34;   教員実施)&#xA;(時刻 &#x9;&#34;教員は授業の開始・終了の時刻を守ろうとしていた&#34;                          教員実施)&#xA;(反応 &#x9;&#34;教員は学生の反応を確かめながら授業を進めていた&#34;                          教員実施)&#xA;(熱意 &#x9;&#34;教員は熱意を持って授業をしていた&#34;                                        教員実施)&#xA;(理解 &#x9;&#34;私はこの授業内容を理解できた&#34;                                            総合評価)&#xA;(役立 &#x9;&#34;私はこの授業で学んだ内容はなんらかの形で将来的に役立つと感じた&#34;          総合評価)&#xA;(満足 &#x9;&#34;私は総合的に判断してこの授業で満足が得られた&#34;                            総合評価)))&#xA;&#xA;;; Japanese short symbol key, quest-symbs, English word short key, English Translation&#xA;(define questions-English &#39;(&#xA;(出席 attended &#34;I attended this class often&#34;)&#xA;(発言 spoke &#34;I made remarks or questions about this class&#34;)&#xA;(取組 engaged &#34;I actively engaged with this subject (I studied before and after class)&#34;)&#xA;(聞取 heard &#34;The teacher&#39;s voice was easy to hear&#34;)&#xA;(資料 seen &#34;The teacher&#39;s board-work, presentations, and printouts were easy to read(see)&#34;)&#xA;(時刻 timed &#34;The teacher started and ended the class on time&#34;)&#xA;(反応 responsive &#34;The teacher checked for student responses in the class&#34;)&#xA;(熱意 enthused &#34;The teacher was enthused to do the class&#34;)&#xA;(理解 comprehended &#34;I comprehended this class&#39;s content&#34;)&#xA;(役立 valued &#34;I felt that the content of this class will be of use in some form in the future&#34;)&#xA;(満足 satisfied &#34;I am satisfied with the class overall&#34;)))&#xA;&#xA;;; number, short symbol, Japanese Sentence, English Translation&#xA;(define responses &#39;((5 特に   &#34;特にそう思う&#34;       &#34;very much&#34;  &#34;I really think so&#34;)&#xA;&#x9;&#x9;    (4 多少   &#34;多少そう思う&#34;&#x9;   &#34;fairly much&#34;  &#34;I somewhat think so&#34;)&#xA;&#x9;&#x9;    (3 どちも &#34;どちらともいえない&#34; &#34;neither&#34;  &#34;I can&#39;t say either way&#34;)&#xA;&#x9;&#x9;    (2 あまり &#34;あまりそう思わない&#34; &#34;not much&#34;  &#34;I do not think so much&#34;)&#xA;&#x9;&#x9;    (1 全く   &#34;全くそう思わない&#34;   &#34;not at all&#34;  &#34;I do not think so at all&#34;)))&#xA;&#xA;;; remove ind results from dep results&#xA;;; and dep results from uni&#xA;(define als-ref&#xA;  (lambda (idx als)&#xA;    (let ((tmp (assv idx als)))&#xA;      (if tmp (cadr tmp) #f))))&#xA;&#xA;(define remove-internal-data&#xA;  (lambda (base umbrella)&#xA;    (map (lambda (list-pair)&#xA;&#x9;   (map - (car list-pair)(cadr list-pair)))&#xA;&#x9; (map list umbrella base))))&#xA;&#xA;;; &#34;w-o&#34; means without or 抜き&#xA;(define removed-prt-into-nme&#xA;  (lambda (bse-als grp-als)&#xA;    (cons &#39;nme (list&#xA;&#x9;  (cons (string-  symbol&#xA;&#x9;&#x9; (string-join (list (symbol-  string (caadr (assoc &#39;nme grp-als)))(symbol-  string (caadr (assoc &#39;nme bse-als)))) &#34;w-o&#34;))&#xA;&#x9;&#x9;(cdr (als-ref &#39;nme grp-als)))))))&#xA;&#xA;(define remove-internal-body-als&#xA;  (lambda (bse-als grp-als)&#xA;    (list (removed-prt-into-nme bse-als grp-als)&#xA;&#x9;  (assoc &#39;smr grp-als) ;; keep the same&#xA;&#x9;  (cons &#39;cls (list&#xA;&#x9;&#x9;      (map - (als-ref &#39;cls grp-als)&#xA;&#x9;&#x9;&#x9;   (als-ref &#39;cls bse-als))))&#xA;&#x9;  (cons &#39;dta (list&#xA;&#x9;&#x9;      (remove-internal-data&#xA;&#x9;&#x9;       (als-ref &#39;dta bse-als)&#xA;&#x9;&#x9;       (als-ref &#39;dta grp-als)))))))&#xA;;; (remove-internal-body-als dep uni)&#xA;&#xA;;; responses must be in form (Int &#34;Str&#34;)&#xA;;; like &#39;(5 &#34;very much&#34; ... ) (4 &#34;多少&#34;)&#xA;(define stack-plot-body&#xA;  ;; Questions Numbers Responses&#xA;  (lambda (Qstns Alst Rspns) ;; Questions, Numbers, Responses&#xA;    (plot (stacked-histogram&#xA;&#x9;   (reverse (map vector Qstns (als-ref &#39;dta Alst)))&#xA;&#x9;   #:invert? #t&#xA;&#x9;   #:add-ticks? #t&#xA;&#x9;   #:labels (map (lambda (l)&#xA;&#x9;&#x9;&#x9;   (format &#34;~s ~s&#34;&#xA;&#x9;&#x9;&#x9;&#x9;   (car l) (cadr l)))&#xA;&#x9;&#x9;&#x9; Rspns)&#xA;&#x9;   #:colors &#39;(-7 -6 -5 -4 -3 -2 -1 0)&#xA;&#x9;   #:line-colors &#39;(-7 -6 -5 -4 -3 -2 -1 0)&#xA;&#x9;   #:styles &#39;(2 4 5 6 3)&#xA;&#x9;   #:line-widths &#39;(1 1 1 1 1)&#xA;&#x9;   #:gap .5&#xA;&#x9;   )&#xA;&#x9;  #:legend-anchor &#39;top-right&#xA;&#x9;  #:width 600&#xA;&#x9;  #:height 250&#xA;&#x9;  #:x-label &#34;枚数 Responses&#34;&#xA;&#x9;  #:y-label &#34;設問 Questions&#34;&#xA;&#x9;  #:title (format &#34;~a ~a ~a&#34; (car (als-ref &#39;nme Alst))&#xA;&#x9;&#x9;&#x9;  (car (als-ref &#39;smr Alst))&#xA;&#x9;&#x9;&#x9;  (cadr (als-ref &#39;smr Alst)))&#xA;&#x9;  )))&#xA;;; (stack-plot-body quest-symbs ind responses)&#xA;;; (stack-plot-body quest-symbs (remove-internal-body-als ind-als dep-als) responses)&#xA;;; (stack-plot-body quest-symbs (remove-internal-body-als ind-als uni-als) responses)&#xA;&#xA;(define als-dat-to-png-nam&#xA;  (lambda (Alst)&#xA;    (format &#34;~a~a~a~a.png&#34;&#xA;&#x9;    (car (als-ref &#39;nme Alst))&#xA;&#x9;    (car (als-ref &#39;smr Alst))&#xA;&#x9;    0&#xA;&#x9;    (cadr (als-ref &#39;smr Alst)))))&#xA;&#xA;;; ;; For printing the commented out plot colors and styles might be&#xA;;; ;; nice, the defaults may be better for comparing in browser&#xA;;; (define stack-plot-body-to-file&#xA;;;   ;; Questions Numbers Responses&#xA;;;   (lambda (Qstns Alst Rspns) ;; Questions, Numbers, Responses&#xA;;;     (plot-file (stacked-histogram&#xA;;; &#x9;   (reverse (map vector Qstns (als-ref &#39;dta Alst)))&#xA;;; &#x9;   #:invert? #t&#xA;;; &#x9;   #:add-ticks? #t&#xA;;; &#x9;   #:labels (map (lambda (l)&#xA;;; &#x9;&#x9;&#x9;   (format &#34;~s ~s&#34;&#xA;;; &#x9;&#x9;&#x9;&#x9;   (car l) (cadr l)))&#xA;;; &#x9;&#x9;&#x9; Rspns)&#xA;;; &#x9;   #:colors &#39;(-7 -6 -5 -4 -3 -2 -1 0)&#xA;;; &#x9;   #:line-colors &#39;(-7 -6 -5 -4 -3 -2 -1 0)&#xA;;; &#x9;   #:styles &#39;(2 4 5 6 3)&#xA;;; &#x9;   #:line-widths &#39;(1 1 1 1 1)&#xA;;; &#x9;   #:gap .5&#xA;;; &#x9;   )&#xA;;; &#x9;  #:legend-anchor &#39;top-right&#xA;;; &#x9;  #:width 600&#xA;;; &#x9;  #:height 250&#xA;;; &#x9;  #:x-label &#34;枚数 Responses&#34;&#xA;;; &#x9;  #:y-label &#34;設問 Questions&#34;&#xA;;; &#x9;  #:title (format &#34;~a ~a ~a&#34; (car (als-ref &#39;nme Alst))&#xA;;; &#x9;&#x9;&#x9;  (car (als-ref &#39;smr Alst))&#xA;;; &#x9;&#x9;&#x9;  (cadr (als-ref &#39;smr Alst)))&#xA;;; &#x9;  ;; file arguments, file name and mode&#xA;;; &#x9;  (als-dat-to-png-nam Alst)&#xA;;; &#x9;  &#39;png&#xA;;; &#x9;  )))&#xA;&#xA;;; end of definitions preparation&#xA;;;; start to write files&#xA;;; (map (lambda (als) (stack-plot-body-to-file quest-symbs als responses)) plot-to-file)&#xA;&#xA;(define plot-to-file (list ind-als dep-als uni-als&#xA;&#x9;&#x9;&#x9;       (remove-internal-body-als ind-als dep-als)&#xA;&#x9;&#x9;&#x9;       (remove-internal-body-als dep-als uni-als)&#xA;&#x9;&#x9;&#x9;       (remove-internal-body-als ind-als uni-als)))&#xA;&#xA;(define stack-deflt-plot-body-to-file&#xA;  ;; Questions Numbers Responses&#xA;  (lambda (Qstns Alst Rspns) ;; Questions, Numbers, Responses&#xA;    (plot-file (stacked-histogram&#xA;&#x9;   (reverse (map vector Qstns (als-ref &#39;dta Alst)))&#xA;&#x9;   #:invert? #t&#xA;&#x9;   #:add-ticks? #t&#xA;&#x9;   #:labels (map (lambda (l)&#xA;&#x9;&#x9;&#x9;   (format &#34;~s ~s&#34;&#xA;&#x9;&#x9;&#x9;&#x9;   (car l) (cadr l)))&#xA;&#x9;&#x9;&#x9; Rspns)&#xA;&#x9;   )&#xA;&#x9;  #:legend-anchor &#39;top-right&#xA;          #:width 800&#xA;&#x9;  #:height 250&#xA;&#x9;  #:x-label &#34;枚数 Responses&#34;&#xA;&#x9;  #:y-label &#34;設問 Questions&#34;&#xA;&#x9;  #:title (format &#34;~a ~a ~a&#34; (car (als-ref &#39;nme Alst))&#xA;&#x9;&#x9;&#x9;  (car (als-ref &#39;smr Alst))&#xA;&#x9;&#x9;&#x9;  (cadr (als-ref &#39;smr Alst)))&#xA;&#x9;  ;; file arguments, file name and mode&#xA;&#x9;  (als-dat-to-png-nam Alst)&#xA;&#x9;  &#39;png&#xA;&#x9;  )))&#xA;&#xA;(map (lambda (als) (stack-deflt-plot-body-to-file quest-symbs als responses)) plot-to-file)&#xA;&#xA;(define png-fls (map als-dat-to-png-nam plot-to-file))&#xA;&#xA;(call-with-output-file &#34;FD-Anketo-Results.html&#34; #:exists &#39;truncate&#xA;  (lambda (out)&#xA;    (output-xml (xhtml&#xA;&#x9;&#x9; (head (title &#34;FD アンケート結果 視覚化 1&#34;)&#xA;&#x9;&#x9;       (meta http-equiv: &#34;Content-Type&#34; content: &#34;text/html;charset=utf-8&#34;)&#xA;&#x9;&#x9;       (style &#34;img.stacked-histogram { margin-bottom: 5px; }&#34;))&#xA;&#x9;&#x9; (body (map (lambda (f) (element &#39;img class: &#34;stacked-histogram&#34;  src: f)) png-fls))) out)))&#xA;&#xA;#Scheme #Racket #FS4FT #FS4FD #facdev #FacultyDevelopment #DataVisualizatoin #アンケート #データ視覚化]]&gt;</description>
      <content:encoded><![CDATA[<p>Racket plot and scribble/html with stacked-histograms and output-xml are working well. It was fun to play with plot keywords and think about printing the data visualizations, but for quick comparisons in the browser the defaults seem better.</p>

<p>I imagine DrRacket will make the code below work with a Windows computer too. How would Windows users be able to find their home directory, Racket&#39;s (current-directory) and get their bowser to show “/FD201801/FD-Anketo-Results.html”...  The file-separator slashes are probably different too. But that sort of detail can be overcome when a Windows user shows an interest in testing the code and visualization...</p>

<p><img src="https://i.snap.as/CthBqvW.png" alt="Screenshot of DrRacket with code and plotted images on generated page in browser window" title="Screenshot of DrRacket with code and plotted images on generated page in browser window"/></p>

<p>It was good training to work with associative lists, to use two a-lists to generate a new a-list. Using a-lists allows for the generation of useful titles and file names that match the data used for the visualization.

教員抜き大学の結果：  大学w-o教員
The image below is a visualization of the university data with one teacher&#39;s results removed.  A teacher&#39;s comment about the difficulty in interpreting result averages without reference to the department averages and the minimum and maximum values prompted the “w-o” data and visualization exercise.</p>

<p><img src="https://i.snap.as/FseoI6Z.image" alt=""/></p>

<p>Reading a Japanese book about Gauche Scheme helped me see how important it is to get the data into structures that make the work go smoothly.</p>

<h3 id="code">code</h3>

<pre><code>#lang racket

;; Generate Data Visualizations for Questionnaire Results
;;  let teachers see their results 
;;   see relations to their department and university
;;  ~/FD201801/FD-Anketo-Results.html

;; 画像ファイル、.htmlページを書き込むフォルダー:directory
(make-directory* &#34;FD201801&#34;)
(current-directory &#34;FD201801&#34;)
(current-directory-for-user &#34;FD201801&#34;)

(require plot) 
(require scribble/html/html) ;; to view png files in browser
(require scribble/html) ;; output-xml to make .html page for browser

;; データを入力し直すところ
(define ind-als ;;教員の連帯リスト associative list
  &#39;((nme (教員 TCR スモール 教養))
    (smr (2018 1 H30 Z)) ;; 学期 SeMesteR
    (cls (1 84))         ;; 授業、教室 CLasS
    (dta ((62 13 9 0 0)   ;; データ、DaTA
	 (19 24 28 6 6)
	 (23 24 27 6 4)
	 (53 22 9 0 0)
	 (35 29 19 0 1)
	 (64 12 7 1 0)
	 (54 19 10 1 0)
	 (69 9 6 0 0)
	 (34 28 16 4 1)
	 (43 25 12 2 1)
	 (35 25 20 2 1)))))

(define dep-als ;;学科 associative list
  &#39;((nme (学科 DPT 教養 大学))
    (smr (2018 1 H30 Z))
    (cls (7 269))
    (dta ((202 41 26 0 0)
    (62 68 99 22 17)
    (72 74 98 14 11)
    (144 67 41 9 8)
    (111 78 55 13 10)
    (171 60 28 5 4)
    (140 65 46 10 8)
    (165 62 27 9 6)
    (96 98 51 14 8)
    (119 76 56 8 8)
    (109 79 60 9 10)))))

(define uni-als ;;大学
  &#39;((nme (大学 UVY 南九州 学園))
    (smr (2018 1 H30 Z))
    (cls (59 2452))
    (dta ((1738 472 206 23 8)
     (495 549 923 195 283)
     (713 765 736 162 65)
     (1400 628 296 86 35)
     (1264 630 384 110 55)
     (1795 446 166 25 13)
     (1378 654 317 59 38)
     (1573 588 230 33 20)
     (976 886 438 99 42)
     (1411 684 289 33 24)
     (1217 740 388 58 38)))))

;; Questions Symbols
(define quest-symbs &#39;(出席 発言 取組 聞取 資料 時刻 反応 熱意 理解 役立 満足))

;; short symbol for Qquestion, Japanese Sentence,  short symbol for Q-type
(define questions &#39;(
(出席 	&#34;私はこの授業によく出席した&#34;                                              学生取組)
(発言 	&#34;私は授業内容について質問や発言した&#34;                                      学生取組)
(取組 	&#34;私はこの科目に積極的に取り組んだ(予習と復習した)&#34;                      学生取組)
(聞取 	&#34;教員の声は聞き取りやすかった。&#34;                                          教員実施)
(資料 	&#34;教員の板書（またはPPT・配布資料など）は読みやすかった（見やすかった）&#34;   教員実施)
(時刻 	&#34;教員は授業の開始・終了の時刻を守ろうとしていた&#34;                          教員実施)
(反応 	&#34;教員は学生の反応を確かめながら授業を進めていた&#34;                          教員実施)
(熱意 	&#34;教員は熱意を持って授業をしていた&#34;                                        教員実施)
(理解 	&#34;私はこの授業内容を理解できた&#34;                                            総合評価)
(役立 	&#34;私はこの授業で学んだ内容はなんらかの形で将来的に役立つと感じた&#34;          総合評価)
(満足 	&#34;私は総合的に判断してこの授業で満足が得られた&#34;                            総合評価)))

;; Japanese short symbol key, quest-symbs, English word short key, English Translation
(define questions-English &#39;(
(出席 attended &#34;I attended this class often&#34;)
(発言 spoke &#34;I made remarks or questions about this class&#34;)
(取組 engaged &#34;I actively engaged with this subject (I studied before and after class)&#34;)
(聞取 heard &#34;The teacher&#39;s voice was easy to hear&#34;)
(資料 seen &#34;The teacher&#39;s board-work, presentations, and printouts were easy to read(see)&#34;)
(時刻 timed &#34;The teacher started and ended the class on time&#34;)
(反応 responsive &#34;The teacher checked for student responses in the class&#34;)
(熱意 enthused &#34;The teacher was enthused to do the class&#34;)
(理解 comprehended &#34;I comprehended this class&#39;s content&#34;)
(役立 valued &#34;I felt that the content of this class will be of use in some form in the future&#34;)
(満足 satisfied &#34;I am satisfied with the class overall&#34;)))

;; number, short symbol, Japanese Sentence, English Translation
(define responses &#39;((5 特に   &#34;特にそう思う&#34;       &#34;very much&#34;  &#34;I really think so&#34;)
		    (4 多少   &#34;多少そう思う&#34;	   &#34;fairly much&#34;  &#34;I somewhat think so&#34;)
		    (3 どちも &#34;どちらともいえない&#34; &#34;neither&#34;  &#34;I can&#39;t say either way&#34;)
		    (2 あまり &#34;あまりそう思わない&#34; &#34;not much&#34;  &#34;I do not think so much&#34;)
		    (1 全く   &#34;全くそう思わない&#34;   &#34;not at all&#34;  &#34;I do not think so at all&#34;)))


;; remove ind results from dep results
;; and dep results from uni
(define als-ref
  (lambda (idx als)
    (let ((tmp (assv idx als)))
      (if tmp (cadr tmp) #f))))

(define remove-internal-data
  (lambda (base umbrella)
    (map (lambda (list-pair)
	   (map - (car list-pair)(cadr list-pair)))
	 (map list umbrella base))))


;; &#34;w-o&#34; means without or 抜き
(define removed-prt-into-nme
  (lambda (bse-als grp-als)
    (cons &#39;nme (list
	  (cons (string-&gt;symbol
		 (string-join (list (symbol-&gt;string (caadr (assoc &#39;nme grp-als)))(symbol-&gt;string (caadr (assoc &#39;nme bse-als)))) &#34;w-o&#34;))
		(cdr (als-ref &#39;nme grp-als)))))))

(define remove-internal-body-als
  (lambda (bse-als grp-als)
    (list (removed-prt-into-nme bse-als grp-als)
	  (assoc &#39;smr grp-als) ;; keep the same
	  (cons &#39;cls (list
		      (map - (als-ref &#39;cls grp-als)
			   (als-ref &#39;cls bse-als))))
	  (cons &#39;dta (list
		      (remove-internal-data
		       (als-ref &#39;dta bse-als)
		       (als-ref &#39;dta grp-als)))))))
;; (remove-internal-body-als dep uni)

;; responses must be in form (Int &#34;Str&#34;)
;; like &#39;(5 &#34;very much&#34; ... ) (4 &#34;多少&#34;)
(define stack-plot-body
  ;; Questions Numbers Responses
  (lambda (Qstns Alst Rspns) ;; Questions, Numbers, Responses
    (plot (stacked-histogram
	   (reverse (map vector Qstns (als-ref &#39;dta Alst)))
	   #:invert? #t
	   #:add-ticks? #t
	   #:labels (map (lambda (l)
			   (format &#34;~s ~s&#34;
				   (car l) (cadr l)))
			 Rspns)
	   #:colors &#39;(-7 -6 -5 -4 -3 -2 -1 0)
	   #:line-colors &#39;(-7 -6 -5 -4 -3 -2 -1 0)
	   #:styles &#39;(2 4 5 6 3)
	   #:line-widths &#39;(1 1 1 1 1)
	   #:gap .5
	   )
	  #:legend-anchor &#39;top-right
	  #:width 600
	  #:height 250
	  #:x-label &#34;枚数 Responses&#34;
	  #:y-label &#34;設問 Questions&#34;
	  #:title (format &#34;~a ~a ~a&#34; (car (als-ref &#39;nme Alst))
			  (car (als-ref &#39;smr Alst))
			  (cadr (als-ref &#39;smr Alst)))
	  )))
;; (stack-plot-body quest-symbs ind responses)
;; (stack-plot-body quest-symbs (remove-internal-body-als ind-als dep-als) responses)
;; (stack-plot-body quest-symbs (remove-internal-body-als ind-als uni-als) responses)

(define als-dat-to-png-nam
  (lambda (Alst)
    (format &#34;~a~a~a~a.png&#34;
	    (car (als-ref &#39;nme Alst))
	    (car (als-ref &#39;smr Alst))
	    0
	    (cadr (als-ref &#39;smr Alst)))))

;; ;; For printing the commented out plot colors and styles might be
;; ;; nice, the defaults may be better for comparing in browser
;; (define stack-plot-body-to-file
;;   ;; Questions Numbers Responses
;;   (lambda (Qstns Alst Rspns) ;; Questions, Numbers, Responses
;;     (plot-file (stacked-histogram
;; 	   (reverse (map vector Qstns (als-ref &#39;dta Alst)))
;; 	   #:invert? #t
;; 	   #:add-ticks? #t
;; 	   #:labels (map (lambda (l)
;; 			   (format &#34;~s ~s&#34;
;; 				   (car l) (cadr l)))
;; 			 Rspns)
;; 	   #:colors &#39;(-7 -6 -5 -4 -3 -2 -1 0)
;; 	   #:line-colors &#39;(-7 -6 -5 -4 -3 -2 -1 0)
;; 	   #:styles &#39;(2 4 5 6 3)
;; 	   #:line-widths &#39;(1 1 1 1 1)
;; 	   #:gap .5
;; 	   )
;; 	  #:legend-anchor &#39;top-right
;; 	  #:width 600
;; 	  #:height 250
;; 	  #:x-label &#34;枚数 Responses&#34;
;; 	  #:y-label &#34;設問 Questions&#34;
;; 	  #:title (format &#34;~a ~a ~a&#34; (car (als-ref &#39;nme Alst))
;; 			  (car (als-ref &#39;smr Alst))
;; 			  (cadr (als-ref &#39;smr Alst)))
;; 	  ;; file arguments, file name and mode
;; 	  (als-dat-to-png-nam Alst)
;; 	  &#39;png
;; 	  )))


;; end of definitions preparation
;;; start to write files
;; (map (lambda (als) (stack-plot-body-to-file quest-symbs als responses)) plot-to-file)

(define plot-to-file (list ind-als dep-als uni-als
			       (remove-internal-body-als ind-als dep-als)
			       (remove-internal-body-als dep-als uni-als)
			       (remove-internal-body-als ind-als uni-als)))

(define stack-deflt-plot-body-to-file
  ;; Questions Numbers Responses
  (lambda (Qstns Alst Rspns) ;; Questions, Numbers, Responses
    (plot-file (stacked-histogram
	   (reverse (map vector Qstns (als-ref &#39;dta Alst)))
	   #:invert? #t
	   #:add-ticks? #t
	   #:labels (map (lambda (l)
			   (format &#34;~s ~s&#34;
				   (car l) (cadr l)))
			 Rspns)
	   )
	  #:legend-anchor &#39;top-right
          #:width 800
	  #:height 250
	  #:x-label &#34;枚数 Responses&#34;
	  #:y-label &#34;設問 Questions&#34;
	  #:title (format &#34;~a ~a ~a&#34; (car (als-ref &#39;nme Alst))
			  (car (als-ref &#39;smr Alst))
			  (cadr (als-ref &#39;smr Alst)))
	  ;; file arguments, file name and mode
	  (als-dat-to-png-nam Alst)
	  &#39;png
	  )))

(map (lambda (als) (stack-deflt-plot-body-to-file quest-symbs als responses)) plot-to-file)

(define png-fls (map als-dat-to-png-nam plot-to-file))


(call-with-output-file &#34;FD-Anketo-Results.html&#34; #:exists &#39;truncate
  (lambda (out)
    (output-xml (xhtml
		 (head (title &#34;FD アンケート結果 視覚化 1&#34;)
		       (meta http-equiv: &#34;Content-Type&#34; content: &#34;text/html;charset=utf-8&#34;)
		       (style &#34;img.stacked-histogram { margin-bottom: 5px; }&#34;))
		 (body (map (lambda (f) (element &#39;img class: &#34;stacked-histogram&#34;  src: f)) png-fls))) out)))

</code></pre>

<p><a href="https://write.as/bs2facdev/tag:Scheme" class="hashtag"><span>#</span><span class="p-category">Scheme</span></a> <a href="https://write.as/bs2facdev/tag:Racket" class="hashtag"><span>#</span><span class="p-category">Racket</span></a> <a href="https://write.as/bs2facdev/tag:FS4FT" class="hashtag"><span>#</span><span class="p-category">FS4FT</span></a> <a href="https://write.as/bs2facdev/tag:FS4FD" class="hashtag"><span>#</span><span class="p-category">FS4FD</span></a> <a href="https://write.as/bs2facdev/tag:facdev" class="hashtag"><span>#</span><span class="p-category">facdev</span></a> <a href="https://write.as/bs2facdev/tag:FacultyDevelopment" class="hashtag"><span>#</span><span class="p-category">FacultyDevelopment</span></a> <a href="https://write.as/bs2facdev/tag:DataVisualizatoin" class="hashtag"><span>#</span><span class="p-category">DataVisualizatoin</span></a> <a href="https://write.as/bs2facdev/tag:%E3%82%A2%E3%83%B3%E3%82%B1%E3%83%BC%E3%83%88" class="hashtag"><span>#</span><span class="p-category">アンケート</span></a> <a href="https://write.as/bs2facdev/tag:%E3%83%87%E3%83%BC%E3%82%BF%E8%A6%96%E8%A6%9A%E5%8C%96" class="hashtag"><span>#</span><span class="p-category">データ視覚化</span></a></p>
]]></content:encoded>
      <guid>https://write.as/bs2facdev/racket-plot-stacked-histograms-show-in-browser-page</guid>
      <pubDate>Tue, 19 Mar 2019 08:59:34 +0000</pubDate>
    </item>
    <item>
      <title>Questionnaire Visualization with Racket Plot: 1 StackedHistograms</title>
      <link>https://write.as/bs2facdev/questionnaire-visualization-with-racket-plot-1-stackedhistograms?pk_campaign=rss-feed</link>
      <description>&lt;![CDATA[アンケートデータの視覚化 with Racket plot&#39;s stacked-histogram&#xA;&#xA;Faculty Development Questionnaires give me an opportunity to work with Racket. Until now the questionnaire data provided opportunities to learn data visualization with two other languages: gnuplot with Philip Janert&#39;s book, and R/ggplot2 with Hadley Wickham&#39;s book. But for more regular work I was using emacs-lisp with org-mode. Without weekly practice with language like gnuplot or R/ggplot2, it was always a struggle to get back into the data manipulation and visualization flow once every six months. Recently my regular work goes well with Scheme.(fn:1) Guile Scheme is more compact that org-mode and emacs-lisp for converting jpg images to png and svg images and for generating worksheets, roll-sheets, and seating charts. However, I am not yet able to graph/plot/chart with Guile. Racket&#39;s plot lets me work well with Questionnaire data.&#xA;&#xA;Racket stacked-histogram with University Data: English Version&#xA;&#xA;It will be interesting to learn how to plot and label points at will, and how to adjust colors, but in the meantime racket/plot&#39;s stacked-histograms provide compact visualizations that may serve as springboards for discussion. I made the English version, to make it easier for non-Japanese readers to follow the code. Seeing two versions clearly shows the advantages of Chinese characters for compact information design.&#xA;&#xA;Racket stacked-histogram with Department Data&#xA;&#xA;There are eleven questions on the school&#39;s questionnaire. The first three questions attempt to gauge students feelings their participation in the class.  What are their feelings about how often they \attended\出席 the class, how much they \spoke\ in the class, and how much they \engaged\ in the class.  The next five questions gauge the students perceptions of how well they \heard\ the teacher&#39;s voice, how they had \seen\ the teacher&#39;s materials, how well \timed\ the teacher&#39;s starting and ending of the classwas, how \responsive\ the teacher was, as well as how \enthused\ the teacher may have been. The last three questions are about overall perceptions of how much the student \comprehended\ and \valued\ the class, ending with a overall ranking of how \satisfied\ the student is with the classes experienced so far. The questionnaires are usually filled out during the 13th or 14th class a 15-class semester. &#xA;!--more--&#xA;Students respond to the questions by circling a number in the range from five to one, inclusive. Five means they \very much\ agree that they frequently \attended\ the class, or that the teacher was \enthused\ (for example). One means that \not at all\ do they agree that the the teacher \timed\ the starting and ending of the class well, or that they \valued\ the classes usefulness in some manner. Teachers are provided with the results of the questionnaires given in the class of their choice.&#xA;&#xA;off-the-shelf or ready-made visualization, &#xA;&#xA;The data entry and visualization is out-sourced. Working with R/ggplot2 and talking with a teacher of statistics gave me the idea that averages/means are not sensible when gauging feelings/perceptions. Our feelings of agreement do not change one unit at a time from &#34;very much&#34; to &#34;not at all&#34;. It would be interesting if there were a unit of measurement like a gram or a centimeter for agreeing, though we may need a rate: like miles per hour for running. &#xA;&#xA;Besides the use of means(平均値) for factors, the changes in scale from question to question can give the impression that 198 is smaller than 102, and that 59 is smaller than 50. Redoing the same sort of bar chart with R/ggplot2 avoids disorientation from scale adjustments. (fn:2)&#xA;&#xA;hand-crafted visualization with R ggplot2&#xA;&#xA;I am not yet able to label points with Racket/plot the way I can do so freely with R/ggplot2. But Racket&#39;s stacked-histogram plots provide for the same sort of visual comparison in a way that is compact enough to allow comparison of three different entities, the individual teacher, the teacher&#39;s department, and the entire university. I don&#39;t yet know how to append plots to a file so I had to use ImageMagick(the code is below) to combine the plot-files. The stacked-histogram approach seems promising too. I feel much more comfortable manipulating data in Scheme with nested maps than I do with half-remembered, half-understood techniques in R. Now if I can learn to place and label points and control colors the way I can with ggplot2 I&#39;ll be able to stay in scheme for a more coherent computing experience and better chance of developing more advanced programming skills.&#xA;&#xA;individual, department, and university stacked-histogram montage&#xA;&#xA;After removing the individual&#39;s results from the deparment&#39;s, and the department&#39;s from the university&#39;s, I have to re-calculate the average class size for the department and university. The quickest way to fix that bug would be to remove AvgClassSize from the title, but I always wonder how much results are influenced simply by class size. With years of data curiosity supplies a number of questions to be explored... &#xA;&#xA;I have three questions about the presentation details:&#xA;How can the legend be replaced with numbers and words inside the bars?&#xA;How can the ends the numbers of responses be placed just inside the end of the bars?&#xA;How can I change to color scheme?&#xA;&#xA;In the documentation I saw an explanation for  \point-label\ on the 2D Renderers page and section for \Colors and Styles\ in the Introduction to Plot: Graph Plotting documentation: so there are places to read and get started working on the details.&#xA;&#xA;Interleaving&#xA;&#xA;I also have to discover ways interleave histograms as shown on the 2D Renderers page. The challenges is how to structure the data so that each question type from each entity: individual, department, and univesity is interleaved and within the question the responses: 5, 4, 3, 2, and 1 are also interleaved. With Racket/Scheme techniques interleaving may be surprisingly within reach.&#xA;&#xA;Racket Documentation on Interleaveing&#xA;&#xA;code&#xA;&#xA;    ;; Generate Data Visualizations for Questionnaire Results&#xA;    ;;  let teachers see their results&#xA;    ;;   in relation to their department and university&#xA;    &#xA;    ;; ind, dep, uni: alternative names&#xA;    (define body-types &#39;((individual 教員) ;; ind&#xA;                         (department 学科)  ;; dep&#xA;                         (university 大学)));; uni&#xA;    &#xA;    ;; Short symbols and English for Questionsattendance,&#xA;    ;; these characters might help avoid repetitions later&#xA;    (define quest-symbs &#39;(出席 発言 取組 聞取 資料 時刻 反応 熱意 理解 役立 満足))&#xA;    &#xA;    ;; short symbol for Qquestion, Japanese Sentence,  short symbol for Q-type&#xA;    (define questions &#39;(&#xA;    (出席   &#34;私はこの授業によく出席した&#34;                                              学生取組)&#xA;    (発言   &#34;私は授業内容について質問や発言した&#34;                                      学生取組)&#xA;    (取組   &#34;私はこの科目に積極的に取り組んだ（予習と復習した）&#34;                      学生取組)&#xA;    (聞取   &#34;教員の声は聞き取りやすかった。&#34;                                          教員実施)&#xA;    (資料   &#34;教員の板書（またはPPT・配布資料など）は読みやすかった（見やすかった）&#34;   教員実施)&#xA;    (時刻   &#34;教員は授業の開始・終了の時刻を守ろうとしていた&#34;                          教員実施)&#xA;    (反応   &#34;教員は学生の反応を確かめながら授業を進めていた&#34;                          教員実施)&#xA;    (熱意   &#34;教員は熱意を持って授業をしていた&#34;                                        教員実施)&#xA;    (理解   &#34;私はこの授業内容を理解できた&#34;                                            総合評価)&#xA;    (役立   &#34;私はこの授業で学んだ内容はなんらかの形で将来的に役立つと感じた&#34;          総合評価)&#xA;    (満足   &#34;私は総合的に判断してこの授業で満足が得られた&#34;                            総合評価)))&#xA;    &#xA;    ;; Japanese short symbol key, English word short key, English Translation&#xA;    (define questions-English &#39;(&#xA;    (出席 attended &#34;I attended this class often&#34;)&#xA;    (発言 spoke &#34;I made remarks or questions about this class&#34;)&#xA;    (取組 engaged &#34;I actively engaged with this subject (I studied before and after class)&#34;)&#xA;    (聞取 heard &#34;The teacher&#39;s voice was easy to hear&#34;)&#xA;    (資料 seen &#34;The teacher&#39;s board-work, presentations, and printouts were easy to read(see)&#34;)&#xA;    (時刻 timed &#34;The teacher started and ended the class on time&#34;)&#xA;    (反応 responsive &#34;The teacher checked for student responses in the class&#34;)&#xA;    (熱意 enthused &#34;The teacher was enthused to do the class&#34;)&#xA;    (理解 comprehended &#34;I comprehended this class&#39;s content&#34;)&#xA;    (役立 valued &#34;I felt that the content of this class will be of use in some form in the future&#34;)&#xA;    (満足 satisfied &#34;I am satisfied with the class overall&#34;)))&#xA;    &#xA;    ;; number, short symbol, Japanese Sentence, English Translation&#xA;    (define responses &#39;(&#xA;                        (5 特に   &#34;特にそう思う&#34;       &#34;very much&#34;  &#34;I really think so&#34;)&#xA;                        (4 多少   &#34;多少そう思う&#34;       &#34;fairly much&#34;  &#34;I somewhat think so&#34;)        &#xA;                        (3 どちも &#34;どちらともいえない&#34; &#34;neither&#34;  &#34;I can&#39;t say either way&#34;)&#xA;                        (2 あまり &#34;あまりそう思わない&#34; &#34;not much&#34;  &#34;I do not think so much&#34;)        &#xA;                        (1 全く   &#34;全くそう思わない&#34;   &#34;not at all&#34;  &#34;I do not think so at all&#34;)))&#xA;    ;; semester data Japanese Year, year, first 1 or second 2 semester&#xA;    (define sem &#39;(H30 2018 1))&#xA;    ;; body data: number of teachers, questionnaires&#xA;    (define uni-dat &#39;(59 2452)) ;;大学&#xA;    (define dep-dat &#39;(7 269))   ;;学科&#xA;    (define ind-dat &#39;(1 84))    ;;教員&#xA;    (define ind ;;教員&#xA;      &#39;((62 13 9 0 0)&#xA;        (19 24 28 6 6)&#xA;        (23 24 27 6 4)&#xA;        (53 22 9 0 0)&#xA;        (35 29 19 0 1)&#xA;        (64 12 7 1 0)&#xA;        (54 19 10 1 0)&#xA;        (69 9 6 0 0)&#xA;        (34 28 16 4 1)&#xA;        (43 25 12 2 1)&#xA;        (35 25 20 2 1)))&#xA;    &#xA;    (define dep ;;学科&#xA;      &#39;((202 41 26 0 0)&#xA;        (62 68 99 22 17)&#xA;        (72 74 98 14 11)&#xA;        (144 67 41 9 8)&#xA;        (111 78 55 13 10)&#xA;        (171 60 28 5 4)&#xA;        (140 65 46 10 8)&#xA;        (165 62 27 9 6)&#xA;        (96 98 51 14 8)&#xA;        (119 76 56 8 8)&#xA;        (109 79 60 9 10)))&#xA;    &#xA;    (define uni ;;大学&#xA;      &#39;((1738 472 206 23 8)&#xA;         (495 549 923 195 283)&#xA;         (713 765 736 162 65)&#xA;         (1400 628 296 86 35)&#xA;         (1264 630 384 110 55)&#xA;         (1795 446 166 25 13)&#xA;         (1378 654 317 59 38)&#xA;         (1573 588 230 33 20)&#xA;         (976 886 438 99 42)&#xA;         (1411 684 289 33 24)&#xA;         (1217 740 388 58 38)))&#xA;    &#xA;    ;; remove ind results from dep results&#xA;    ;; and dep results from uni&#xA;    (define remove-internal-body&#xA;      (lambda (base umbrella)&#xA;        (map (lambda (list-pair)&#xA;               (map - (car list-pair)(cadr list-pair)))&#xA;             (map list umbrella base))))&#xA;    ;; (remove-internal-body dep uni)&#xA;    &#xA;    ;; responses must be in form (Int &#34;Str&#34;)&#xA;    ;; like &#39;(5 &#34;very much&#34; ... ) (4 &#34;多少&#34;)&#xA;    (define stack-plot-body&#xA;      ;; Questions Numbers Responses&#xA;      (lambda (Qs Ns Rs) ;; Questions, Numbers, Responses&#xA;        (plot (stacked-histogram&#xA;               (reverse (map vector Qs Ns))&#xA;               #:invert? #t&#xA;               #:add-ticks? #t&#xA;               #:labels (map (lambda (l)&#xA;                               (format &#34;~s ~s&#34;&#xA;                                       (car l) (cadr l)))&#xA;                             Rs))&#xA;              #:legend-anchor &#39;top-right)))&#xA;    ;; (stack-plot-body quest-symbs ind responses)&#xA;    ;; replace ind with dep and then uni to visualize&#xA;    ;;  responses for umbrella bodies&#xA;    (parameterize&#xA;        ((plot-width 800)&#xA;         (plot-x-label &#34;枚数 Responses&#34;)&#xA;         (plot-y-label &#34;設問 Questions&#34;))&#xA;      (stack-plot-body quest-symbs ind responses))&#xA;    &#xA;    (parameterize&#xA;        ((plot-width 800)&#xA;         (plot-x-label &#34;枚数 Responses&#34;)&#xA;         (plot-y-label &#34;設問 Questions&#34;))&#xA;      (list (stack-plot-body quest-symbs ind responses)&#xA;            (stack-plot-body quest-symbs dep responses)&#xA;            (stack-plot-body quest-symbs uni responses)))&#xA;    ;; Questions Numbers Responses SemesterData BodyData&#xA;    &#xA;    (define stack-plot-body-ttld&#xA;      (lambda (Qs Ns Rs Sd Bd)&#xA;        (plot (stacked-histogram&#xA;               (reverse (map vector Qs Ns))&#xA;               #:invert? #t&#xA;               #:add-ticks? #t&#xA;               #:labels (map (lambda (l)&#xA;                               (format &#34;~s ~s&#34;&#xA;                                       (car l)(cadr l)))&#xA;                             Rs))&#xA;               #:legend-anchor &#39;top-right&#xA;               #:title (format &#34;Year:~a Semester:~a Teachers:~a Students:~a&#34;&#xA;                               (cadr Sd) (caddr Sd)&#xA;                               (car Bd)(cadr Bd)))))&#xA;    &#xA;    (stack-plot-body-ttld quest-symbs dep responses sem dep-dat)&#xA;    &#xA;    (parameterize&#xA;        ((plot-width 800)&#xA;         (plot-height 300)&#xA;         (plot-x-label &#34;枚数 Responses&#34;)&#xA;         (plot-y-label &#34;設問 Questions&#34;))&#xA;      (list (stack-plot-body-ttld quest-symbs ind responses sem ind-dat)&#xA;            (stack-plot-body-ttld quest-symbs dep responses sem dep-dat)&#xA;            (stack-plot-body-ttld quest-symbs uni responses sem uni-dat)))&#xA;    &#xA;    (require plot/no-gui)   ;; for plot-file&#xA;    (require racket/format) ;; for ~r #:precision&#xA;    ;; Questions Numbers Rsponses SemesterData BodyData BodyTypeString&#xA;    (define stack-plot-body-ttld-file&#xA;      (lambda (Qs Ns Rs Sd Bd Bt)&#xA;        (plot-file (stacked-histogram&#xA;               (reverse (map vector Qs Ns))&#xA;               #:invert? #t&#xA;               #:add-ticks? #t&#xA;               #:labels (map (lambda (l)&#xA;                               (format &#34;~s ~s&#34;&#xA;                                       (car l)(cadr l)))&#xA;                             Rs))&#xA;               #:legend-anchor &#39;top-right&#xA;               #:title (format &#34;Year:~a Semester:~a Teachers:~a Students:~a AvgClassSize:~a&#34;&#xA;                               (cadr Sd) (caddr Sd)&#xA;                               (car Bd)(cadr Bd)&#xA;                               (~r (/ (cadr Bd)(car Bd)) #:precision 1))&#xA;               (format &#34;~a~a~a~a~a.png&#34; Bt &#xA;                       (cadr Sd) (caddr Sd)&#xA;                       (car Bd)(cadr Bd))&#xA;               &#39;png)))&#xA;    ;;(stack-plot-body-ttld-file quest-symbs dep responses sem dep-dat &#34;Dep&#34;)    ;; Success!!&#xA;    &#xA;    (parameterize&#xA;        ((plot-width 700)&#xA;         (plot-height 250)&#xA;         (plot-x-label &#34;枚数 Responses&#34;)&#xA;         (plot-y-label &#34;設問 Questions&#34;))&#xA;      (stack-plot-body-ttld-file quest-symbs ind responses sem ind-dat &#34;TCRwo&#34;)&#xA;      (stack-plot-body-ttld-file quest-symbs (remove-internal-body ind dep) responses sem dep-dat &#34;DPTwoTCR&#34;)&#xA;      (stack-plot-body-ttld-file quest-symbs (remove-internal-body dep uni) responses sem uni-dat &#34;UVYwoDPT&#34;))&#xA;    &#xA;    (define RsEng (map (lambda (l) (list (car l) (cadddr l))) responses))&#xA;    (define QsEng (map cadr questions-English))&#xA;    &#xA;    (parameterize&#xA;        ((plot-width 700)&#xA;         (plot-height 250)&#xA;         (plot-x-label &#34;Responses&#34;)&#xA;         (plot-y-label &#34;Question Type&#34;))&#xA;      (stack-plot-body-ttld-file QsEng uni RsEng sem uni-dat &#34;UniEng&#34;))&#xA;    ;; end of stacked-histogram code&#xA;&#xA;    montage -tile 1x -geometry 750x TCRwo20181184.png DPTwoTCR201817269.png UVYwoDPT20181592452.png  TCRwoDPTwoUVYwo.png&#xA;&#xA;footnotes&#xA;&#xA;(fn:1) Regular Work with Scheme&#xA;    https://write.as/bs2gs/batch-convert-image-files&#xA;    https://write.as/bs2gs/from-csv-file-generate-roll-sheet-and-seat-chart&#xA;    https://write.as/bs2gs/from-list-data-to-html-page-with-guile&#xA;&#xA;(fn:2)&#xA;    https://write.as/bs2facdev/anketo-questionnaire-visualization-with-r-ggplot2&#xA;&#xA; #Racket #RacketLang #RacketLanguage #Scheme #Programming #DataVisualization #FD #FacDev #FacultyDevelopment #アンケート #データ視覚化 #FS4FT #FS4FD &#xA;&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<h3 id="アンケートデータの視覚化-with-racket-plot-s-stacked-histogram">アンケートデータの視覚化 with Racket plot&#39;s stacked-histogram</h3>

<p>Faculty Development Questionnaires give me an opportunity to work with Racket. Until now the questionnaire data provided opportunities to learn data visualization with two other languages: gnuplot with Philip Janert&#39;s book, and R/ggplot2 with Hadley Wickham&#39;s book. But for more regular work I was using emacs-lisp with org-mode. Without weekly practice with language like gnuplot or R/ggplot2, it was always a struggle to get back into the data manipulation and visualization flow once every six months. Recently my regular work goes well with Scheme.(fn:1) Guile Scheme is more compact that org-mode and emacs-lisp for converting jpg images to png and svg images and for generating worksheets, roll-sheets, and seating charts. However, I am not yet able to graph/plot/chart with Guile. Racket&#39;s plot lets me work well with Questionnaire data.</p>

<p><img src="https://i.snap.as/FPsULdW.png" alt="Racket stacked-histogram with University Data: English Version"/></p>

<p>It will be interesting to learn how to plot and label points at will, and how to adjust colors, but in the meantime racket/plot&#39;s stacked-histograms provide compact visualizations that may serve as springboards for discussion. I made the English version, to make it easier for non-Japanese readers to follow the code. Seeing two versions clearly shows the advantages of Chinese characters for compact information design.</p>

<p><img src="https://i.snap.as/k2DLx3L.png" alt="Racket stacked-histogram with Department Data"/></p>

<p>There are eleven questions on the school&#39;s questionnaire. The first three questions attempt to gauge students feelings their participation in the class.  What are their feelings about how often they `attended`出席 the class, how much they `spoke` in the class, and how much they `engaged` in the class.  The next five questions gauge the students perceptions of how well they `heard` the teacher&#39;s voice, how they had `seen` the teacher&#39;s materials, how well `timed` the teacher&#39;s starting and ending of the classwas, how `responsive` the teacher was, as well as how `enthused` the teacher may have been. The last three questions are about overall perceptions of how much the student `comprehended` and `valued` the class, ending with a overall ranking of how `satisfied` the student is with the classes experienced so far. The questionnaires are usually filled out during the 13th or 14th class a 15-class semester.

Students respond to the questions by circling a number in the range from five to one, inclusive. Five means they `very much` agree that they frequently `attended` the class, or that the teacher was `enthused` (for example). One means that `not at all` do they agree that the the teacher `timed` the starting and ending of the class well, or that they `valued` the classes usefulness in some manner. Teachers are provided with the results of the questionnaires given in the class of their choice.</p>

<p><img src="https://i.snap.as/2TF832k.png" alt="off-the-shelf or ready-made visualization, "/></p>

<p>The data entry and visualization is out-sourced. Working with R/ggplot2 and talking with a teacher of statistics gave me the idea that averages/means are not sensible when gauging feelings/perceptions. Our feelings of agreement do not change one unit at a time from “very much” to “not at all”. It would be interesting if there were a unit of measurement like a gram or a centimeter for agreeing, though we may need a rate: like miles per hour for running.</p>

<p>Besides the use of means(平均値) for factors, the changes in scale from question to question can give the impression that 198 is smaller than 102, and that 59 is smaller than 50. Redoing the same sort of bar chart with R/ggplot2 avoids disorientation from scale adjustments. (fn:2)</p>

<p><img src="https://i.snap.as/xtetJP7.png" alt="hand-crafted visualization with R ggplot2"/></p>

<p>I am not yet able to label points with Racket/plot the way I can do so freely with R/ggplot2. But Racket&#39;s stacked-histogram plots provide for the same sort of visual comparison in a way that is compact enough to allow comparison of three different entities, the individual teacher, the teacher&#39;s department, and the entire university. I don&#39;t yet know how to append plots to a file so I had to use ImageMagick(the code is below) to combine the plot-files. The stacked-histogram approach seems promising too. I feel much more comfortable manipulating data in Scheme with nested maps than I do with half-remembered, half-understood techniques in R. Now if I can learn to place and label points and control colors the way I can with ggplot2 I&#39;ll be able to stay in scheme for a more coherent computing experience and better chance of developing more advanced programming skills.</p>

<p><img src="https://i.snap.as/JYredDW.png" alt="individual, department, and university stacked-histogram montage"/></p>

<p>After removing the individual&#39;s results from the deparment&#39;s, and the department&#39;s from the university&#39;s, I have to re-calculate the average class size for the department and university. The quickest way to fix that bug would be to remove AvgClassSize from the title, but I always wonder how much results are influenced simply by class size. With years of data curiosity supplies a number of questions to be explored...</p>

<p>I have three questions about the presentation details:
1.  How can the legend be replaced with numbers and words inside the bars?
2.  How can the ends the numbers of responses be placed just inside the end of the bars?
3.  How can I change to color scheme?</p>

<p>In the documentation I saw an explanation for  `point-label` on the <em>2D Renderers</em> page and section for `Colors and Styles` in the <em>Introduction</em> to <em>Plot: Graph Plotting</em> documentation: so there are places to read and get started working on the details.</p>

<h1 id="interleaving">Interleaving</h1>

<p>I also have to discover ways interleave histograms as shown on the <em>2D Renderers</em> page. The challenges is how to structure the data so that each question type from each entity: individual, department, and univesity is interleaved and within the question the responses: 5, 4, 3, 2, and 1 are also interleaved. With Racket/Scheme techniques interleaving may be surprisingly within reach.</p>

<p><img src="https://i.snap.as/TW8EHAk.png" alt="Racket Documentation on Interleaveing"/></p>

<h4 id="code">code</h4>

<p>    ;; Generate Data Visualizations for Questionnaire Results
    ;;  let teachers see their results
    ;;   in relation to their department and university</p>

<p>    ;; ind, dep, uni: alternative names
    (define body-types &#39;((individual 教員) ;; ind
                         (department 学科)  ;; dep
                         (university 大学)));; uni</p>

<p>    ;; Short symbols and English for Questionsattendance,
    ;; these characters might help avoid repetitions later
    (define quest-symbs &#39;(出席 発言 取組 聞取 資料 時刻 反応 熱意 理解 役立 満足))</p>

<p>    ;; short symbol for Qquestion, Japanese Sentence,  short symbol for Q-type
    (define questions &#39;(
    (出席   “私はこの授業によく出席した”                                              学生取組)
    (発言   “私は授業内容について質問や発言した”                                      学生取組)
    (取組   “私はこの科目に積極的に取り組んだ（予習と復習した）”                      学生取組)
    (聞取   “教員の声は聞き取りやすかった。”                                          教員実施)
    (資料   “教員の板書（またはPPT・配布資料など）は読みやすかった（見やすかった）”   教員実施)
    (時刻   “教員は授業の開始・終了の時刻を守ろうとしていた”                          教員実施)
    (反応   “教員は学生の反応を確かめながら授業を進めていた”                          教員実施)
    (熱意   “教員は熱意を持って授業をしていた”                                        教員実施)
    (理解   “私はこの授業内容を理解できた”                                            総合評価)
    (役立   “私はこの授業で学んだ内容はなんらかの形で将来的に役立つと感じた”          総合評価)
    (満足   “私は総合的に判断してこの授業で満足が得られた”                            総合評価)))</p>

<p>    ;; Japanese short symbol key, English word short key, English Translation
    (define questions-English &#39;(
    (出席 attended “I attended this class often”)
    (発言 spoke “I made remarks or questions about this class”)
    (取組 engaged “I actively engaged with this subject (I studied before and after class)”)
    (聞取 heard “The teacher&#39;s voice was easy to hear”)
    (資料 seen “The teacher&#39;s board-work, presentations, and printouts were easy to read(see)”)
    (時刻 timed “The teacher started and ended the class on time”)
    (反応 responsive “The teacher checked for student responses in the class”)
    (熱意 enthused “The teacher was enthused to do the class”)
    (理解 comprehended “I comprehended this class&#39;s content”)
    (役立 valued “I felt that the content of this class will be of use in some form in the future”)
    (満足 satisfied “I am satisfied with the class overall”)))</p>

<p>    ;; number, short symbol, Japanese Sentence, English Translation
    (define responses &#39;(
                        (5 特に   “特にそう思う”       “very much”  “I really think so”)
                        (4 多少   “多少そう思う”       “fairly much”  “I somewhat think so”)<br/>
                        (3 どちも “どちらともいえない” “neither”  “I can&#39;t say either way”)
                        (2 あまり “あまりそう思わない” “not much”  “I do not think so much”)<br/>
                        (1 全く   “全くそう思わない”   “not at all”  “I do not think so at all”)))
    ;; semester data Japanese Year, year, first 1 or second 2 semester
    (define sem &#39;(H30 2018 1))
    ;; body data: number of teachers, questionnaires
    (define uni-dat &#39;(59 2452)) ;;大学
    (define dep-dat &#39;(7 269))   ;;学科
    (define ind-dat &#39;(1 84))    ;;教員
    (define ind ;;教員
      &#39;((62 13 9 0 0)
        (19 24 28 6 6)
        (23 24 27 6 4)
        (53 22 9 0 0)
        (35 29 19 0 1)
        (64 12 7 1 0)
        (54 19 10 1 0)
        (69 9 6 0 0)
        (34 28 16 4 1)
        (43 25 12 2 1)
        (35 25 20 2 1)))</p>

<p>    (define dep ;;学科
      &#39;((202 41 26 0 0)
        (62 68 99 22 17)
        (72 74 98 14 11)
        (144 67 41 9 8)
        (111 78 55 13 10)
        (171 60 28 5 4)
        (140 65 46 10 8)
        (165 62 27 9 6)
        (96 98 51 14 8)
        (119 76 56 8 8)
        (109 79 60 9 10)))</p>

<p>    (define uni ;;大学
      &#39;((1738 472 206 23 8)
         (495 549 923 195 283)
         (713 765 736 162 65)
         (1400 628 296 86 35)
         (1264 630 384 110 55)
         (1795 446 166 25 13)
         (1378 654 317 59 38)
         (1573 588 230 33 20)
         (976 886 438 99 42)
         (1411 684 289 33 24)
         (1217 740 388 58 38)))</p>

<p>    ;; remove ind results from dep results
    ;; and dep results from uni
    (define remove-internal-body
      (lambda (base umbrella)
        (map (lambda (list-pair)
               (map – (car list-pair)(cadr list-pair)))
             (map list umbrella base))))
    ;; (remove-internal-body dep uni)</p>

<p>    ;; responses must be in form (Int “Str”)
    ;; like &#39;(5 “very much” ... ) (4 “多少”)
    (define stack-plot-body
      ;; Questions Numbers Responses
      (lambda (Qs Ns Rs) ;; Questions, Numbers, Responses
        (plot (stacked-histogram
               (reverse (map vector Qs Ns))
               #:invert? <a href="https://write.as/bs2facdev/tag:t" class="hashtag"><span>#</span><span class="p-category">t</span></a>
               #:add-ticks? <a href="https://write.as/bs2facdev/tag:t" class="hashtag"><span>#</span><span class="p-category">t</span></a>
               #:labels (map (lambda (l)
                               (format “~s ~s”
                                       (car l) (cadr l)))
                             Rs))
              #:legend-anchor &#39;top-right)))
    ;; (stack-plot-body quest-symbs ind responses)
    ;; replace ind with dep and then uni to visualize
    ;;  responses for umbrella bodies
    (parameterize
        ((plot-width 800)
         (plot-x-label “枚数 Responses”)
         (plot-y-label “設問 Questions”))
      (stack-plot-body quest-symbs ind responses))</p>

<p>    (parameterize
        ((plot-width 800)
         (plot-x-label “枚数 Responses”)
         (plot-y-label “設問 Questions”))
      (list (stack-plot-body quest-symbs ind responses)
            (stack-plot-body quest-symbs dep responses)
            (stack-plot-body quest-symbs uni responses)))
    ;; Questions Numbers Responses SemesterData BodyData</p>

<p>    (define stack-plot-body-ttld
      (lambda (Qs Ns Rs Sd Bd)
        (plot (stacked-histogram
               (reverse (map vector Qs Ns))
               #:invert? <a href="https://write.as/bs2facdev/tag:t" class="hashtag"><span>#</span><span class="p-category">t</span></a>
               #:add-ticks? <a href="https://write.as/bs2facdev/tag:t" class="hashtag"><span>#</span><span class="p-category">t</span></a>
               #:labels (map (lambda (l)
                               (format “~s ~s”
                                       (car l)(cadr l)))
                             Rs))
               #:legend-anchor &#39;top-right
               #:title (format “Year:~a Semester:~a Teachers:~a Students:~a”
                               (cadr Sd) (caddr Sd)
                               (car Bd)(cadr Bd)))))</p>

<p>    (stack-plot-body-ttld quest-symbs dep responses sem dep-dat)</p>

<p>    (parameterize
        ((plot-width 800)
         (plot-height 300)
         (plot-x-label “枚数 Responses”)
         (plot-y-label “設問 Questions”))
      (list (stack-plot-body-ttld quest-symbs ind responses sem ind-dat)
            (stack-plot-body-ttld quest-symbs dep responses sem dep-dat)
            (stack-plot-body-ttld quest-symbs uni responses sem uni-dat)))</p>

<p>    (require plot/no-gui)   ;; for plot-file
    (require racket/format) ;; for ~r #:precision
    ;; Questions Numbers Rsponses SemesterData BodyData BodyTypeString
    (define stack-plot-body-ttld-file
      (lambda (Qs Ns Rs Sd Bd Bt)
        (plot-file (stacked-histogram
               (reverse (map vector Qs Ns))
               #:invert? <a href="https://write.as/bs2facdev/tag:t" class="hashtag"><span>#</span><span class="p-category">t</span></a>
               #:add-ticks? <a href="https://write.as/bs2facdev/tag:t" class="hashtag"><span>#</span><span class="p-category">t</span></a>
               #:labels (map (lambda (l)
                               (format “~s ~s”
                                       (car l)(cadr l)))
                             Rs))
               #:legend-anchor &#39;top-right
               #:title (format “Year:~a Semester:~a Teachers:~a Students:~a AvgClassSize:~a”
                               (cadr Sd) (caddr Sd)
                               (car Bd)(cadr Bd)
                               (~r (/ (cadr Bd)(car Bd)) #:precision 1))
               (format “~a~a~a~a~a.png” Bt
                       (cadr Sd) (caddr Sd)
                       (car Bd)(cadr Bd))
               &#39;png)))
    ;;(stack-plot-body-ttld-file quest-symbs dep responses sem dep-dat “Dep”)    ;; Success!!</p>

<p>    (parameterize
        ((plot-width 700)
         (plot-height 250)
         (plot-x-label “枚数 Responses”)
         (plot-y-label “設問 Questions”))
      (stack-plot-body-ttld-file quest-symbs ind responses sem ind-dat “TCRwo”)
      (stack-plot-body-ttld-file quest-symbs (remove-internal-body ind dep) responses sem dep-dat “DPTwoTCR”)
      (stack-plot-body-ttld-file quest-symbs (remove-internal-body dep uni) responses sem uni-dat “UVYwoDPT”))</p>

<p>    (define RsEng (map (lambda (l) (list (car l) (cadddr l))) responses))
    (define QsEng (map cadr questions-English))</p>

<p>    (parameterize
        ((plot-width 700)
         (plot-height 250)
         (plot-x-label “Responses”)
         (plot-y-label “Question Type”))
      (stack-plot-body-ttld-file QsEng uni RsEng sem uni-dat “UniEng”))
    ;; end of stacked-histogram code</p>

<p>    montage -tile 1x -geometry 750x TCRwo20181184.png DPTwoTCR201817269.png UVYwoDPT20181592452.png  TCRwoDPTwoUVYwo.png</p>

<h1 id="footnotes">footnotes</h1>
<ul><li><p>(fn:1) Regular Work with Scheme</p>
<ul><li><a href="https://write.as/bs2gs/batch-convert-image-files">https://write.as/bs2gs/batch-convert-image-files</a></li>
<li><a href="https://write.as/bs2gs/from-csv-file-generate-roll-sheet-and-seat-chart">https://write.as/bs2gs/from-csv-file-generate-roll-sheet-and-seat-chart</a></li>
<li><a href="https://write.as/bs2gs/from-list-data-to-html-page-with-guile">https://write.as/bs2gs/from-list-data-to-html-page-with-guile</a></li></ul></li>

<li><p>(fn:2)</p>
<ul><li><a href="https://write.as/bs2facdev/anketo-questionnaire-visualization-with-r-ggplot2">https://write.as/bs2facdev/anketo-questionnaire-visualization-with-r-ggplot2</a></li></ul></li></ul>

<p> <a href="https://write.as/bs2facdev/tag:Racket" class="hashtag"><span>#</span><span class="p-category">Racket</span></a> <a href="https://write.as/bs2facdev/tag:RacketLang" class="hashtag"><span>#</span><span class="p-category">RacketLang</span></a> <a href="https://write.as/bs2facdev/tag:RacketLanguage" class="hashtag"><span>#</span><span class="p-category">RacketLanguage</span></a> <a href="https://write.as/bs2facdev/tag:Scheme" class="hashtag"><span>#</span><span class="p-category">Scheme</span></a> <a href="https://write.as/bs2facdev/tag:Programming" class="hashtag"><span>#</span><span class="p-category">Programming</span></a> <a href="https://write.as/bs2facdev/tag:DataVisualization" class="hashtag"><span>#</span><span class="p-category">DataVisualization</span></a> <a href="https://write.as/bs2facdev/tag:FD" class="hashtag"><span>#</span><span class="p-category">FD</span></a> <a href="https://write.as/bs2facdev/tag:FacDev" class="hashtag"><span>#</span><span class="p-category">FacDev</span></a> <a href="https://write.as/bs2facdev/tag:FacultyDevelopment" class="hashtag"><span>#</span><span class="p-category">FacultyDevelopment</span></a> <a href="https://write.as/bs2facdev/tag:%E3%82%A2%E3%83%B3%E3%82%B1%E3%83%BC%E3%83%88" class="hashtag"><span>#</span><span class="p-category">アンケート</span></a> <a href="https://write.as/bs2facdev/tag:%E3%83%87%E3%83%BC%E3%82%BF%E8%A6%96%E8%A6%9A%E5%8C%96" class="hashtag"><span>#</span><span class="p-category">データ視覚化</span></a> <a href="https://write.as/bs2facdev/tag:FS4FT" class="hashtag"><span>#</span><span class="p-category">FS4FT</span></a> <a href="https://write.as/bs2facdev/tag:FS4FD" class="hashtag"><span>#</span><span class="p-category">FS4FD</span></a></p>
]]></content:encoded>
      <guid>https://write.as/bs2facdev/questionnaire-visualization-with-racket-plot-1-stackedhistograms</guid>
      <pubDate>Mon, 18 Mar 2019 05:54:35 +0000</pubDate>
    </item>
  </channel>
</rss>