guile-charting.texi 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  1. \input texinfo @c -*-texinfo-*-
  2. @c %**start of header
  3. @setfilename guile-charting.info
  4. @settitle Guile Charting
  5. @c %**end of header
  6. @copying
  7. This manual is for Guile Charting (version 0.2.0, updated 19 September
  8. 2014)
  9. Copyright 2014 Andy Wingo
  10. @quotation
  11. Permission is granted to copy, distribute and/or modify this document
  12. under the terms of the GNU Lesser General Public License as published by
  13. the Free Software Foundation; either version 3 of the License or (at
  14. your option) any later version. You should have received a copy of the
  15. GNU Lesser General Public License along with this manual; if not, see
  16. http://www.gnu.org/licenses/.
  17. @end quotation
  18. @end copying
  19. @dircategory The Algorithmic Language Scheme
  20. @direntry
  21. * Guile Charting: (guile-charting.info). Making graphs and charts with Guile Scheme.
  22. @end direntry
  23. @titlepage
  24. @title Guile Charting
  25. @subtitle version 0.2.0, updated 19 September 2014
  26. @author Andy Wingo (@email{wingo@@pobox.com})
  27. @page
  28. @vskip 0pt plus 1filll
  29. @insertcopying
  30. @end titlepage
  31. @ifnottex
  32. @node Top
  33. @top Guile Charting
  34. @insertcopying
  35. @menu
  36. * charting:: Main charting interface
  37. * charting draw:: Lower-level drawing operators
  38. * Concept Index::
  39. * Function Index::
  40. @end menu
  41. @end ifnottex
  42. @iftex
  43. @shortcontents
  44. @end iftex
  45. @node charting
  46. @chapter (charting)
  47. @section Overview
  48. @section Usage
  49. @anchor{charting make-bar-chart}@defun make-bar-chart [title] [data] [write-to-png] [bar-width] [group-spacing] [chart-height] [max-y] [chart-params] [legend-params] [ytick-label-formatter] [bar-value-formatter]
  50. Make a bar chart.
  51. The format of @var{data} is defined as follows:
  52. @table @var
  53. @item data
  54. (@var{group}+)
  55. @item group
  56. (@var{group-label} @var{bar}+)
  57. @item group-label
  58. A string, to be written to the X axis.
  59. @item bar
  60. (@var{height} @var{bar-params}?)
  61. @item height
  62. The bar height, as a number.
  63. @item bar-params
  64. A property list suitable to passing to @ref{charting draw draw-bar}.
  65. @end table
  66. This function returns the cairo surface. By default, make-chart will
  67. create an image surface, but you may override this by passing a
  68. @code{#:make-surface} function in the @var{chart-params}. In this way
  69. you can render charts to any surface supported by Cairo, e.g. PS, PDF,
  70. SVG, GDK, etc.
  71. The #:write-to-png option will write the chart out to the PNG file that
  72. you name.
  73. An example invocation might look like:
  74. @example
  75. (make-bar-chart "Average Height at Iihenda JSS"
  76. '(("Grade 9" (150 "Boys") (140 "Girls"))
  77. ("Grade 10" (150 "Boys")
  78. (140 "Girls" (#:y+-bracket 5 #:y--bracket 4.5))))
  79. #:write-to-png "/tmp/graph.png")
  80. @end example
  81. @end defun
  82. @anchor{charting make-chart}@defun make-chart [title] [chart-height] [chart-width] [font-family] [line-width] [title-text-height] [axis-text-height] [x-axis-label] [y-axis-label] [tick-size] [y-axis-ticks] [x-axis-ticks] [y-axis-tick-labels] [x-axis-tick-labels] [x-axis-tick-mode] [y-axis-tick-mode] [chart-margin] [margin] [padding-left] [padding-right] [padding-top] [padding-bottom] [make-surface]
  83. Make a chart.
  84. @var{tick-lables} is an alist of label-value pairs, where the value is
  85. given in chart height coordinates. The label can be #f.
  86. This function makes the basic chart, setting up the basics like the
  87. title, axes, etc. You probably don't want to call this unless you are
  88. making a custom chart type.
  89. This function returns a cairo context whose coordinate system has been
  90. flipped so that the origin of the chart is (0, 0), with positive in the
  91. northeast quadrant.
  92. @end defun
  93. @anchor{charting make-page-map}@defun make-page-map [title] [data] [write-to-png] [margin] [page-size] [page-width] [page-height] [page-spacing] [title-text-height] [text-height] [label-bar-spacing] [font-family]
  94. @verbatim
  95. Make a page map.
  96. A page map shows the components of a one-dimensional space. Each
  97. component has a label, a start, and a size. The result is a graphical
  98. representation of the space, divided in @@var@{page-size@} strips, along
  99. with a summary list of the different components.
  100. The format of @@var@{data@} is as follows:
  101. @@example
  102. ((@@var@{label@} . (@@var@{start@} . @@var@{size@})) ...)@}
  103. @@end example
  104. @@var@{label@} should be a string. @@var@{start@} and @@var@{size@} should be
  105. numbers.
  106. The #:write-to-png option will write the chart out to the PNG file
  107. that you name.
  108. An example invocation might look like:
  109. @@example
  110. (make-page-map
  111. "foo.so"
  112. '((".text" 1024 65535)
  113. (".data" 65536 20)
  114. (".rodata" 65556 200))
  115. #:write-to-png "foo.png")
  116. @@end example
  117. @end verbatim
  118. @end defun
  119. @anchor{charting make-performance-chart}@defun make-performance-chart [title] [data] [write-to-png] [box-width] [box-spacing] [test-spacing] [chart-height] [max-y] [min-y] [chart-params] [legend-params] [ytick-label-formatter] [box-value-formatter]
  120. Make a performance chart.
  121. A performance chart compares runtimes for some set of tests across some
  122. set of scenarios.
  123. The format of @var{data} is defined as follows:
  124. @example
  125. ((@var{scenario} (@var{test} @var{data-point} ...) ...) ...)
  126. @end example
  127. @var{scenario} and @var{test} should be strings. @var{data-point}
  128. should be numbers.
  129. The resulting plot will have time on the Y axis, and one X axis entry
  130. for each test. Each test/scenario data set will be represented as a box
  131. plot. In the future we should add more options (for example, a small
  132. vertical histogram on the plot).
  133. This function returns the cairo surface. By default, make-chart will
  134. create an image surface, but you may override this by passing a
  135. @code{#:make-surface} function in the @var{chart-params}. In this way
  136. you can render charts to any surface supported by Cairo, e.g. PS, PDF,
  137. SVG, GDK, etc.
  138. The #:write-to-png option will write the chart out to the PNG file that
  139. you name.
  140. An example invocation might look like:
  141. @example
  142. (make-performance-chart
  143. "Gabriel Benchmarks"
  144. '(("guile-1.8"
  145. ("tak" 0.12 0.13 0.17)
  146. ("fib" 1.13 1.24 1.05))
  147. ("guile-2.0"
  148. ("tak" 0.05 0.051 0.047)
  149. ("fib" 0.64 0.59 0.71)))
  150. #:write-to-png "/tmp/graph.png")
  151. @end example
  152. @end defun
  153. @anchor{charting make-performance-series}@defun make-performance-series [title] [data] [write-to-png] [box-width] [box-spacing] [test-spacing] [chart-height] [max-y] [min-y] [chart-params] [annotations] [ytick-label-formatter] [box-value-formatter]
  154. Make a performance chart.
  155. A performance chart compares runtimes for some set of tests across some
  156. set of scenarios.
  157. The format of @var{data} is defined as follows:
  158. @example
  159. ((@var{x} @var{data-point} ...) ...)
  160. @end example
  161. @var{x} and @var{data-point} should be numbers.
  162. The resulting plot will have time on the Y axis, and one X axis entry
  163. for each test. Each data set will be represented as a box plot. In the
  164. future we should add more options (for example, a small vertical
  165. histogram on the plot).
  166. This function returns the cairo surface. By default, make-chart will
  167. create an image surface, but you may override this by passing a
  168. @code{#:make-surface} function in the @var{chart-params}. In this way
  169. you can render charts to any surface supported by Cairo, e.g. PS, PDF,
  170. SVG, GDK, etc.
  171. The #:write-to-png option will write the chart out to the PNG file that
  172. you name.
  173. An example invocation might look like:
  174. @example
  175. (make-performance-chart
  176. "Gabriel Benchmarks"
  177. '(("guile-1.8"
  178. ("tak" 0.12 0.13 0.17)
  179. ("fib" 1.13 1.24 1.05))
  180. ("guile-2.0"
  181. ("tak" 0.05 0.051 0.047)
  182. ("fib" 0.64 0.59 0.71)))
  183. #:write-to-png "/tmp/graph.png")
  184. @end example
  185. @end defun
  186. @anchor{charting make-scatter-plot}@defun make-scatter-plot [title] [data] [write-to-png] [test-spacing] [chart-height] [min-x] [max-x] [min-y] [max-y] [log-x-base] [log-y-base] [chart-params] [legend-params] [x-axis-label] [y-axis-label] [tick-label-formatter]
  187. Make a scatter plot.
  188. A scatter plot shows a number of series as individual points.
  189. The format of @var{data} is defined as follows:
  190. @example
  191. ((@var{series} (@var{x} . @var{y}) ...) ...)
  192. @end example
  193. @var{series} should be a string. @var{x} and @var{y} should be numbers.
  194. This function returns the cairo surface. By default, make-chart will
  195. create an image surface, but you may override this by passing a
  196. @code{#:make-surface} function in the @var{chart-params}. In this way
  197. you can render charts to any surface supported by Cairo, e.g. PS, PDF,
  198. SVG, GDK, etc.
  199. The #:write-to-png option will write the chart out to the PNG file that
  200. you name.
  201. An example invocation might look like:
  202. @example
  203. (make-scatter-plot
  204. "MPG for cars"
  205. '(("ford" (1 . 2) (2 . 3))
  206. ("opel" (1.2 . 3.5) (4.5 . 1)))
  207. #:write-to-png "/tmp/graph.png")
  208. @end example
  209. @end defun
  210. @node charting draw
  211. @chapter (charting draw)
  212. @section Overview
  213. @verbatim
  214. @end verbatim
  215. @section Usage
  216. @anchor{charting draw draw-annotations}@defun draw-annotations [cr] [annotations] [xticks] [width] [height]
  217. @end defun
  218. @anchor{charting draw draw-axis-label}@defun draw-axis-label [cr] [text] [text-height] [axis-length] [vertical?]
  219. Draw an axis label.
  220. The label will be drawn such that the current position of @var{cr} is
  221. the closest corner of the label's bounding box.
  222. @end defun
  223. @anchor{charting draw draw-background}@defun draw-background [cr]
  224. Draw the background.
  225. @end defun
  226. @anchor{charting draw draw-bar}@defun draw-bar [cr] [height] [scale] [bar-width] [bar-value-formatter] [series] [decorator]
  227. Draw a single bar.
  228. @var{cr} is expected to have been placed at the lower left corner of
  229. where the bar should be. @var{decorator} is a property list that can be
  230. passed to @ref{charting draw draw-decorator}.
  231. @end defun
  232. @anchor{charting draw draw-bar-group}@defun draw-bar-group [cr] [data] [bar-width] [scale] [bar-value-formatter]
  233. Draw a group of bars.
  234. @var{data} is a property list suitable for passing to @ref{charting draw
  235. draw-bar}. @var{cr} is expected to have been positioned along the x
  236. axis in the center of where the bar group should be displayed.
  237. @end defun
  238. @anchor{charting draw draw-bar-legend}@defun draw-bar-legend [cr] [data] [width] [text-height] [font-family] [horizontal-spacing] [vertical-spacing]
  239. Draw a "bar legend".
  240. A bar legend is meant to show what categories exist, as well as
  241. indicating their contribution to a graph. Use a bar legend if it would
  242. be confusing to label some other chart in which the pixel count of a
  243. category is proportional to its magnitude, but you want to make sure to
  244. label all categories, even those with small magnitudes.
  245. @var{data} is as in @ref{charting draw draw-page-map}. The legend will
  246. be written below the current position of @var{cr}.
  247. @end defun
  248. @anchor{charting draw draw-chart-area}@defun draw-chart-area [cr] [width] [height]
  249. Draw the actual box for the chart background.
  250. @var{cr} is expected to have been positioned at the origin.
  251. @end defun
  252. @anchor{charting draw draw-decorator}@defun draw-decorator [cr] [scale] [label] [y+-bracket] [y--bracket] [y-bracket]
  253. Draw a decorator.
  254. A decorator is something drawn around a point, such as error bars. This
  255. function currently supports drawing error bars in the Y direction, which
  256. are specified individually as @var{y+-bracket} and @var{y--bracket}.
  257. @end defun
  258. @anchor{charting draw draw-grid}@defun draw-grid [cr] [ticks] [width] [vertical?]
  259. Draw grid lines.
  260. @var{ticks} is a list of positions in the current cairo coordinate
  261. system. @var{width} is the that the grid lines should be: the chart
  262. width of @var{vertical?}, and the height otherwise.
  263. @end defun
  264. @anchor{charting draw draw-legend}@defun draw-legend [cr] [expand-right?] [expand-down?] [measure-only?] [text-height] [draw-outlines?] [draw-background?] [text-measurer] [series-list]
  265. Draw a legend.
  266. @var{series-list} is expected to be a list of series names. The
  267. @var{cr} is expected to be positioned at one of the corners of the
  268. legend; @var{expand-right?} and @var{expand-down?} control which way the
  269. legend will be rendered.
  270. @end defun
  271. @anchor{charting draw draw-page-map}@defun draw-page-map [cr] [data] [chart-width] [chart-height] [page-size] [page-height] [page-spacing]
  272. Draw a page map for the given data set.
  273. @var{data} := @code{(@var{label} . (@var{start} . @var{size})) ...)}
  274. @var{label} is a string, and @var{start} and @var{size} are numbers.
  275. @var{cr} is expected to have been positioned at the lower-left corner of
  276. the chart area.
  277. @end defun
  278. @anchor{charting draw draw-perf-series}@defun draw-perf-series [cr] [data] [xticks] [box-width] [box-spacing] [min-y] [y-scale] [box-value-formatter]
  279. Draw a group of boxes corresponding to runs of one benchmark in
  280. different scenarios.
  281. @var{data} := @code{(@var{x} @var{point} ...) ...)}
  282. , where the series is a string, and the points are numbers. @var{cr} is
  283. expected to have been positioned along the x axis in the center of where
  284. the data for the test should be displayed.
  285. @end defun
  286. @anchor{charting draw draw-perf-test}@defun draw-perf-test [cr] [data] [box-width] [box-spacing] [min-y] [y-scale] [box-value-formatter]
  287. Draw a group of boxes corresponding to runs of one benchmark in
  288. different scenarios.
  289. Each scenario corresponds to a series. The format of @var{data} is
  290. @code{((@var{series} @var{point} ...) ...)}, where the series is a
  291. string, and the points are numbers. @var{cr} is expected to have been
  292. positioned along the x axis in the center of where the data for the test
  293. should be displayed.
  294. @end defun
  295. @anchor{charting draw draw-point}@defun draw-point [cr] [x] [y] [label]
  296. Draw a point at the current position.
  297. @end defun
  298. @anchor{charting draw draw-tick-labels}@defun draw-tick-labels [cr] [tick-labels] [tick-size] [vertical?] [text-height]
  299. Draw tick labels on an axis.
  300. @var{tick-labels} is an alist of label-position pairs, where position is
  301. in the current cairo coordinate system, along one axis.
  302. @end defun
  303. @anchor{charting draw draw-ticks}@defun draw-ticks [cr] [ticks] [tick-size] [vertical?]
  304. Draw ticks on an axis.
  305. @var{ticks} is a list of positions in the current cairo coordinate
  306. system.
  307. @end defun
  308. @anchor{charting draw draw-title}@defun draw-title [cr] [text] [font-size]
  309. Draw a title.
  310. @var{cr} is expected to have been positioned at the lower boundary of
  311. where the title should be written, in the center.
  312. @end defun
  313. @anchor{charting draw reset-colors!}@defun reset-colors!
  314. @end defun
  315. @node Concept Index
  316. @unnumbered Concept Index
  317. @printindex cp
  318. @node Function Index
  319. @unnumbered Function Index
  320. @printindex fn
  321. @bye