Wiki
Download
Manual
Eggs
API
Tests
Bugs
show
edit
history
You can edit this page using
wiki syntax
for markup.
Article contents:
[[tags: egg]] == slib-charplot [[toc:]] === Description An ''opinionated'' port of the [[http://people.csail.mit.edu/jaffer/SLIB|SLIB]] character plotting library. For SLIB documentation see [[http://people.csail.mit.edu/jaffer/slib/Character-Plotting.html#Character- Plotting|charplot]]. === Documentation '''Note''' that the SLIB documentation describes {{charplot:dimensions}}, and other plot defining variables, that are ''not'' exported here. Rather {{parameter}}s are provided. Also, the {{plot}} and {{histograph}} procedures here accept optional arguments. ===== Usage <enscript language=scheme> (import slib-charplot) </enscript> ===== plot <procedure>(plot COORDS [X-LABEL [Y-LABEL [FILL?]]])</procedure> Display a 2D plot of the {{COORDS}}, an {{array}}, {{list}} or {{vector}} of ''coordinate''. With x,y axes label strings, {{X-LABEL}} & {{Y-LABEL}}. And the line vs filled graph type determined by {{FILL?}}. ; {{COORDS}} : {{(or array list vector)}} ; coordinate data elements ; {{X-LABEL}} : {{string}} ; x axis label, default see {{(plot-labels}} ; {{Y-LABEL}} : {{string}} ; y axis label, default see {{(plot-labels}} ; {{FILL?}} : {{boolean}} ; line is {{#f}} & filled is {{#t}}, default {{#f}} The elements of a 1-dim {{list}} are {{Y}}, the missing {{X}} value is generated from {{[0 .. c-1]}}, where {{c}} is the cardinality of the {{list}}. The elements of a 2-dim {{list}} are of the form {{(X Y1 ... Yn)}}, where {{(<= 1 n N)}}; {{N}} is {{10}}, limited by the {{(string-length (curves-chars))}}. Other accepted forms are: {{(X . Y)}} & {{(X (Y1 ... Yn))}}, which are interpreted as {{(X Y)}} & {{(X Y1 ... Yn)}}, respectively. The elements of a 1-dim {{array}} or {{vector}} are of type {{Y}} or {{(Y1 ... Yn)}}. The missing {{X}} value is generated from {{[0 .. c-1]}}, where {{c}} is the cardinality of the {{array}} or {{vector}}. The generated data is then {{(X Y ...)}}. The elements of a 2-dim {{array}} are interpreted as {{(X Y ...)}}. The following {{COORDS}} produce the same plot: * {{(list->array 2 '#() '((0 12 21) (1 21 12)))}} * {{#((12 21) (21 12))}} * {{((0 12 21) (1 21 12))}} <procedure>(plot FUNC [X1 [X2 [NPTS]]])</procedure> Plots the function of the single-argument {{FUNC}} over the range {{X1}} to {{X2}}. If the optional integer argument {{NPTS}} is supplied, it specifies the number of points to evaluate func at. ; {{FUNC}} : {{(number -> float)}} ; function to plot ; {{X1}} : {{number}} ; plot range start, default {{0}} ; {{X2}} : {{number}} ; plot range end, default {{1}} ; {{NPTS}} : {{exact-integer}} ; number of points to evaluate {{FUNC}}, default {{64}} ===== histograph <procedure>(histograph DATA [LABEL])</procedure> Creates and displays a histogram of the numerical values contained in vector or list {{DATA}}. ; {{DATA}} : {{(or list vector)}} ; elements are {{number}} ; {{LABEL}} : {{string}} ; plot label, default see {{(plot-labels}} ===== plot-labels <parameter>(plot-labels [LABELER]) -> ((or array list vector) --> string string)</parameter> Procedure to supply default labels for each plot axis, x & y. Must be able to handle 1 & 2 dimensional data, supplying "" for missing y-axis data. The default {{LABELER}} axis labels are {{"" ""}}. ===== plot-dimensions <parameter>(plot-dimensions [DIMS]) -> (or boolean (list exact-integer exact-integer))</parameter> A list of the maximum height (number of lines) and maximum width (number of columns) for the graph, its scales, and labels. The default value uses the output-port-height and output-port-width of current-output-port at plot time. ; {{DIMS}} : {{(or #f (list exact-integer exact-integer))}} ; (Height-rows Width-columns), default {{#f}} The left-margin effects the width consumed. The effective minimum dimensions are {{(4 (+ 5 (plot-left-margin)))}}. Use this instead of {{charplot:dimensions}}. ===== plot-left-margin <parameter>(plot-left-margin [WID]) -> exact-integer</parameter> ; {{WID}} : {{(or #f exact-integer)}} ; Width-columns, default {{2}} {{2}} is the the minimum value. Use this instead of {{charplot:left-margin}}. ===== xborder-char ===== yborder-char ===== xaxis-char ===== yaxis-char ===== xtick-char ===== bar-char <parameter>(xborder-char [CHAR]) -> char</parameter> <parameter>(yborder-char [CHAR]) -> char</parameter> <parameter>(xaxis-char [CHAR]) -> char</parameter> <parameter>(yaxis-char [CHAR]) -> char</parameter> <parameter>(xtick-char [CHAR]) -> char</parameter> <parameter>(bar-char [CHAR]) -> char</parameter> Use these instead of {{char:xborder}}, {{char:yborder}}, {{char:xaxis}}, {{char:yaxis}}, {{char:xtick}} & {{char:bar}}. ===== curves-chars <parameter>(curves-chars [CHARS]) -> exact-integer</parameter> ; {{CHARS}} : {{(or #f string)}} ; characters to use for the plot curve, {{#f}} uses the default set. Use this instead of {{char:curves}}. === Example * RNG Distribution <enscript highlight=scheme> (import (chicken random) (srfi 42) slib-charplot) (parameterize ((plot-dimensions '(20 40))) (plot (vector-ec (: i 64) (pseudo-random-real))) ) ;=> _________________________ 8/5|-: | | : | 7/5|-: | | : | 6/5|-: | | : | 1|-: * * | | : * ** ** | 4/5|-: * | | * * *** | 3/5|-:***** ** * | | : * * ** * ** * | 2/5|-: * ** ** | | :* * * * | 1/5|-* * * * * * * | | :** ** * * * | 0|-:---------**-*----------| |_:_____._____:_____._____| 0 40 80 </enscript> === Author Aubrey Jaffer === Maintainer [[/users/kon-lovett|Kon Lovett]] === Repository This egg is hosted on the CHICKEN Subversion repository: [[https://anonymous@code.call-cc.org/svn/chicken-eggs/release/5/slib-charplot|https://anonymous@code.call-cc.org/svn/chicken-eggs/release/5/slib-charplot]] If you want to check out the source code repository of this egg and you are not familiar with Subversion, see [[/egg-svn-checkout|this page]]. === Requirements [[srfi-63]] === Version history ; 1.2.3 : Allow 1-dim {{list}} {{plot}}. Fix {{plot}} signature. ; 1.2.2 : . ; 1.2.1 : . ; 1.2.0 : Add {{plot-labels}}. ; 1.1.7 : . ; 1.1.6 : . ; 1.1.5 : . ; 1.1.4 : . ; 1.1.3 : . ; 1.1.2 : {{histograph}} label optional. ; 1.1.1 : . ; 1.1.0 : {{plot}} labels & range optional. ; 1.0.3 : {{plot}} accepts a {{SRFI-63}} {{array}}. ; 1.0.0 : C5 release. === License Copyright (C) 1992, 1993, 2001, 2003 Aubrey Jaffer Permission to copy this software, to modify it, to redistribute it, to distribute modified versions, and to use it for any purpose is granted, subject to the following restrictions and understandings. 1. Any copy made of this software must include this copyright notice in full. 2. I have made no warranty or representation that the operation of this software will be error-free, and I am under no obligation to provide any services, by way of maintenance, update, or otherwise. 3. In conjunction with products arising from the use of this material, there shall be no use of my name in any advertising, promotional, or sales literature without prior written consent in each case.
Description of your changes:
I would like to authenticate
Authentication
Username:
Password:
Spam control
What do you get when you multiply 6 by 0?