histogram-2d-graphics.rkt
#lang racket
;;; Science Collection
;;; histogram-2d-graphics.rkt
;;; Copyright (c) 2004-2011 M. Douglas Williams
;;;
;;; This file is part of the Science Collection.
;;;
;;; The Science Collection is free software: you can redistribute it and/or
;;; modify it under the terms of the GNU Lesser General Public License as
;;; published by the Free Software Foundation, either version 3 of the License
;;; or (at your option) any later version.
;;;
;;; The Science Collection is distributed in the hope that it will be useful,
;;; but WITHOUT WARRANTY; without even the implied warranty of MERCHANTABILITY
;;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
;;; License for more details.
;;;
;;; You should have received a copy of the GNU Lesser General Public License
;;; along with the Science Collection.  If not, see
;;; <http://www.gnu.org/licenses/>.
;;;
;;; -------------------------------------------------------------------
;;;
;;; This module implements the graphics for 2D histograms.
;;;
;;; Version  Date      Description
;;; 1.0.0    09/29/04  Marked as ready for Release 1.0.  (Doug
;;;                    Williams)
;;; 3.0.0    06/09/08  Changes required for V4.0.  (Doug Williams)
;;; 3.0.1    07/01/08  Changed axes labels.  (Doug Williams)
;;; 4.0.0    08/15/11  Changed the header and restructured the code. (MDW)

(require "histogram-2d.rkt"
         plot
         "plot-histogram-2d.ss")

(define histogram-2d-plot
  (case-lambda
    ((h title)
     (let ((bins (histogram-2d-bins h))
           (x-ranges (histogram-2d-x-ranges h))
           (y-ranges (histogram-2d-y-ranges h)))
       (plot3d (histogram-2d (list bins x-ranges y-ranges))
               #:x-min (vector-ref x-ranges 0)
               #:x-max (vector-ref x-ranges (- (vector-length x-ranges) 1))
               #:x-label "X"
               #:y-min (vector-ref y-ranges 0)
               #:y-max (vector-ref y-ranges (- (vector-length y-ranges) 1))
               #:y-label "Y"
               #:z-min 0
               #:z-max (histogram-2d-max h)
               #:z-label "Count"
               #:title title)))
    ((h)
     (histogram-2d-plot h "2D Histogram"))))

(provide/contract
 (histogram-2d-plot
  (case-> (-> histogram-2d? string? any)
          (-> histogram-2d? any))))