← bsmall2

Plain Plots with Racket

DrRacket Screenshot

Plain Plot for Seven Disease Reproduction Numbers

#lang racket

(require plot plot/utils) ;; source: ;; ; https://www.vox.com/2020/2/18/21142009/coronavirus-covid19-china-wuhan-deaths-pandemic (define data-lists '((Corona-Virus 2 3.11) (Zika 3 6.6) (Measles 11 18) (Ebola 2 ) (HIV 3.6 3.7) (Flu 1.3 ) (Noro 1.6 3.7)))

(define sorted-lists (sort data-lists #:key last <)) ;; sorted-lists

(define (0line x y) (lines (list (vector 0 y) (vector x y)) #:width 2.5))

(define (Xxline x1 x2 y) (lines (list (vector x1 y) (vector x2 y)) #:width 1))

(define (0Xxline x1 x2 y) (list (0line x1 y) (Xxline x1 x2 y)))

(define (label-disease-R0 dise-list y) (define label-strings (map –>plot-label dise-list)) (define label-string (string-append (first label-strings) “: “ (string-join (rest label-strings) “<—>“))) (point-label (vector 0 y) label-string #:point-sym 'none))

(define (plot-a-R0 d-list y) (define line-y (– y .3)) (if (= 2 (length d-list)) (list (0line (second d-list) line-y) (label-disease-R0 d-list y)) (list (0Xxline (second d-list) (third d-list) line-y) (label-disease-R0 d-list y))))

(define Title-1 “Reproduction numbers for various diseases: “) (define Title-2 “... one sick person is like to infect how many?”) (define source-url-a “https://www.vox.com/2020/2/18/21142009/") (define source-url-b “ coronavirus-covid19-china-wuhan-deaths-pandemic”) (define x-max (+ 1 (last (argmax last sorted-lists)))) (define y-max (add1 (length sorted-lists))) (parameterize ((plot-decorations? #f)) (plot ;;(0Xxline 2 3.11 3) ;; (plot-a-R0 (last sorted-lists) 3) (list (point-label (vector 0 (– y-max .3)) Title-1 #:point-sym 'none) (point-label (vector 0 (– y-max .8)) Title-2 #:point-sym 'none) (point-label (vector 0 (– y-max 1.3)) source-url-a #:point-sym 'none #:size 8) (point-label (vector 0 (– y-max 1.6)) source-url-b #:point-sym 'none #:size 8) (for/list ([d-list sorted-lists] [y (in-naturals)]) (plot-a-R0 d-list y))) #:x-min –.5 #:x-max x-max #:y-min -1 #:y-max y-max #:title “Reproduction Numbers for Various Diseases” ) )