On this page:
2.1 Data Sci Pict
2.2 Data Sci Pict
2.3 Data Sci Pict
2.4 Data Sci Pict
2.5 Data Sci Pict
2.6 Data Sci Pict
2.7 Data Sci Pict
2.8 Data Sci Pict
2.9 Data Sci Pict
2.10 Data Sci Pict
2.11 Data Sci Pict
2.12 Data Sci Pict

2 Data Visualization - Procedural Pictures

2.1 Data Sci Pict

read
Procedurally generate an image of two small circles side by side.
code
#lang data-sci
 
(hc-append (circle 10) (circle 10))

2.2 Data Sci Pict

read
Procedurally generate an image of four small circles arranged a 2x2 grid.
code
#lang data-sci
 
(define (two-circles)
   (hc-append (circle 10) (circle 10)))
 
(vc-append (two-circles) (two-circles))

2.3 Data Sci Pict

read
Procedurally generate an image of three 2x2 grids of circles arranged in a row. Make the middle grid twice as large as the others.
code
#lang data-sci
 
(define (two-circles)
   (hc-append (circle 10) (circle 10)))
 
(define (four-circles)
   (vc-append (two-circles) (two-circles)))
 
(hc-append
  (four-circles)
  (scale (four-circles) 2)
  (four-circles))

2.4 Data Sci Pict

read
Prodedurally generate an image of text that is upside down.
code
#lang data-sci
 
(rotate (text "This is upside down") pi)

2.5 Data Sci Pict

read
Procedurally generate an image of text that is sideways.
code
#lang data-sci
 
(rotate (text "This is sideways") (/ pi 2))

2.6 Data Sci Pict

read
Procedurally generate an image of text that is double the size of the default.
code
#lang data-sci
 
(scale (text "This is big") 2)

2.7 Data Sci Pict

read
Procedurally generate an image of text that is sideways and double the size of the default.
code
#lang data-sci
 
(scale
  (rotate (text "This is sideways") (/ pi 2))
  2)

2.8 Data Sci Pict

read
Procedurally generate an image of red text.
code
#lang data-sci
 
(colorize (text "This is red") "red")

2.9 Data Sci Pict

read
Procedurally generate an image of green text that is rotated sideways.
code
#lang data-sci
 
(rotate
  (colorize
   (text "This is green and sideways")
   "green")
  (/ pi 2))

2.10 Data Sci Pict

read
Procedurally generate an image of a rectangle with a green border
code
#lang data-sci
 
(rectangle
  200
  200
  #:border-width 10
  #:border-color "green")

2.11 Data Sci Pict

read
Procedurally generate an image of text inside a green box.
code
#lang data-sci
 
(cc-superimpose
  (text "I am in a green box")
  (rectangle
   300
   150
   #:border-width 10
   #:border-color "green"))

2.12 Data Sci Pict

read
Procedurally generate a column of four boxes with text inside. Make the first and third box green and the second and fourth box red.
code
#lang data-sci
 
(define green-box
   (cc-superimpose
    (text "This is green")
    (rectangle
     200
     200
     #:border-width 10
     #:border-color "green")))
 
(define red-box
   (cc-superimpose
    (text "This is red")
    (rectangle
     200
     200
     #:border-width 10
     #:border-color "red")))
 
(vc-append green-box red-box green-box red-box)