Questionnaire Visualization with Racket Plot: 1 StackedHistograms

アンケートデータの視覚化 with Racket plot's stacked-histogram

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's book, and R/ggplot2 with Hadley Wickham'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's plot lets me work well with Questionnaire data.

Racket stacked-histogram with University Data: English Version

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'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.

Racket stacked-histogram with Department Data

There are eleven questions on the school'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's voice, how they had `seen` the teacher's materials, how well `timed` the teacher'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.

off-the-shelf or ready-made visualization,

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.

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)

hand-crafted visualization with R ggplot2

I am not yet able to label points with Racket/plot the way I can do so freely with R/ggplot2. But Racket'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's department, and the entire university. I don'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'll be able to stay in scheme for a more coherent computing experience and better chance of developing more advanced programming skills.

individual, department, and university stacked-histogram montage

After removing the individual's results from the deparment's, and the department's from the university'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...

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?

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.

Interleaving

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.

Racket Documentation on Interleaveing

code

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

;; ind, dep, uni: alternative names (define body-types '((individual 教員) ;; ind (department 学科) ;; dep (university 大学)));; uni

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

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

;; Japanese short symbol key, English word short key, English Translation (define questions-English '( (出席 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's voice was easy to hear”) (資料 seen “The teacher'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'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”)))

;; number, short symbol, Japanese Sentence, English Translation (define responses '( (5 特に “特にそう思う” “very much” “I really think so”) (4 多少 “多少そう思う” “fairly much” “I somewhat think so”)
(3 どちも “どちらともいえない” “neither” “I can't say either way”) (2 あまり “あまりそう思わない” “not much” “I do not think so much”)
(1 全く “全くそう思わない” “not at all” “I do not think so at all”))) ;; semester data Japanese Year, year, first 1 or second 2 semester (define sem '(H30 2018 1)) ;; body data: number of teachers, questionnaires (define uni-dat '(59 2452)) ;;大学 (define dep-dat '(7 269)) ;;学科 (define ind-dat '(1 84)) ;;教員 (define ind ;;教員 '((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)))

(define dep ;;学科 '((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 ;;大学 '((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)))

;; 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)

;; responses must be in form (Int “Str”) ;; like '(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? #t #:add-ticks? #t #:labels (map (lambda (l) (format “~s ~s” (car l) (cadr l))) Rs)) #:legend-anchor '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))

(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

(define stack-plot-body-ttld (lambda (Qs Ns Rs Sd Bd) (plot (stacked-histogram (reverse (map vector Qs Ns)) #:invert? #t #:add-ticks? #t #:labels (map (lambda (l) (format “~s ~s” (car l)(cadr l))) Rs)) #:legend-anchor 'top-right #:title (format “Year:~a Semester:~a Teachers:~a Students:~a” (cadr Sd) (caddr Sd) (car Bd)(cadr Bd)))))

(stack-plot-body-ttld quest-symbs dep responses sem dep-dat)

(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)))

(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? #t #:add-ticks? #t #:labels (map (lambda (l) (format “~s ~s” (car l)(cadr l))) Rs)) #:legend-anchor '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)) 'png))) ;;(stack-plot-body-ttld-file quest-symbs dep responses sem dep-dat “Dep”) ;; Success!!

(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”))

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

(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

montage -tile 1x -geometry 750x TCRwo20181184.png DPTwoTCR201817269.png UVYwoDPT20181592452.png TCRwoDPTwoUVYwo.png

footnotes

#Racket #RacketLang #RacketLanguage #Scheme #Programming #DataVisualization #FD #FacDev #FacultyDevelopment #アンケート #データ視覚化 #FS4FT #FS4FD