racket/plot

Set plot area

Ouverte

#7 ouverte le 9 juil. 2015

 (15 commentaires) (0 réaction) (0 personne assignée)Racket (37 forks)github user discovery
help wanted

Métriques du dépôt

Stars
 (45 étoiles)
Métriques de merge PR
 (Aucune PR mergée en 30 j)

Description

It's hard to align plots with different-sized axis labels. See below -- these are equal-sized figures vl-append-ed together (code is far below)

out

Suggestions

  • Add parameters to set plot area, rather than overall plot+axis labels area
  • Add option to pad labels to a fixed width

Code

#lang racket

(require plot/pict pict racket/class)

(define (make-ticks #:multiplier [mul 1])
  (ticks (lambda (lo hi)
           (for/list ([i (in-range lo hi)])
             (pre-tick i #t)))
         (lambda (lo hi pre)
           (for/list ([pt (in-list pre)]
                      [i (in-naturals)])
             (number->string (* mul i))))))

(define (make-plot m)
  (parameterize ([plot-y-ticks (make-ticks #:multiplier m)])
  (plot-pict (function (lambda (x) x))
    #:x-min 0
    #:x-max 5
    #:y-min 0
    #:y-max 5
    #:width 90
    #:height 90)))

(define plt (vl-append 0 (make-plot 1) (make-plot 10000)))

(send (pict->bitmap plt) save-file "maligned.png" 'png)

Guide contributeur