racket/plot

Set plot area

オープン

#7 opened on 2015/07/09

 (15 件のコメント) (0 件のリアクション) (0 人の担当者)Racket (37 件のフォーク)github user discovery
help wanted

Repository metrics

Stars
 (45 個のスター)
PR merge metrics
 (30d に merged PR はありません)

説明

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)

コントリビューターガイド