Tulip Amalie <tulip@bicompact.space>
Graphite is a library designed for producing specific kinds of common graphs/plots, while making decisions about the data being plotted. Graphite is designed to switch between different types of plots relatively seamlessly, without changing anything about the underlying data’s structure.
Graphite is built on top of, and does not replace, plot. For many applications (e.g. 3D plotting, continuous data, interactive plots, etc), plot will be a far better fit.
All of the data-sets that are referred to in this documentation (organdata, oecd, etc) are available here.
A tutorial on graphite is also available; Graphite: a guided tour.
procedure
#:mappingmapping[ #:widthwidth#:heightheight#:titletitle#:x-labelx-label#:x-transformx-transform#:x-convx-conv#:x-minx-min#:x-maxx-max#:y-labely-label#:y-transformy-transform#:y-convy-conv#:y-miny-min#:y-maxy-max#:facet-wrapfacet-wrap#:legend-anchorlegend-anchor#:themetheme]data:data-frame?mapping:aes?renderer:graphite-renderer?
Every column is a variable.
Every row is an observation.
Every cell is a single value.
The required argument #:mapping takes a aes? that dictates aesthetics to be applied to every renderer in the specified tree. Generally, you will want at least an x-axis (#:x).
The #:x-conv and #:y-conv arguments, if given, perform pre-processing of the x-axis and y-axis variable (when said variables are not automatically determined). For example, if you wanted to place dates on the x-axis, this could be a function converting your preferred date format to seconds since the UNIX epoch.
The #:x-transform and #:y-transform arguments, if given, take a transform? to adjust the x and y axes, as well as the ticks. For example, if you wanted to place a logarithmic transform on the x-axis, you could specify logarithmic-transform . Transforms are applied after the respective #:x-conv or #:y-conv function, if present.
When given, the #:x-min (etc.) arguments determine the bounds of the plot, but not the bounds of the individual renderers. For this, the data should be trimmed before being passed in.
The aesthetic #:facet, specified in the #:mapping argument, dictates whether to facet on a single categorical variable. If this is selected, Graphite will split the plot into subplots based on that variable, into a grid. This aesthetic will cause unexpected behavior if not applied globally.
The optional #:facet-wrap argument dictates how many columns should be drawn before wrapping to a new line. By default, this is the square root of the number of observations in the #:facet variable, creating a grid.
pict:pict?path:path-string?
Aesthetic mappings are used to map a given "aesthetic" (such as the x-axis, y-axis, or color) to a variable. When doing this, the given aesthetic will be "split" on that variable. Every renderer, as well as graph , takes an aesthetic mapping using the #:mapping keyword.
These objects are generally passed with the #:mapping keyword to either the graph procedure or to each individual graphite-renderer? in the render tree. They dictate various aesthetics, dictating how to display the data (such as colors, variables, et cetera), with behavior being dictated by each renderer.
procedure
( aes-with/c #:<key>contract...)→contract?
contract:contract?
procedure
( aes-containing/c #:<key>contract...)→contract?
contract:contract?
struct
(struct graphite-renderer (functionmetadata))
Contains both a thunk returning a plot render tree, and an association list of parameters (generally plot parameters) to values, used when a renderer requires certain parameters to be set.
procedure
#:x-maxx-max#:y-miny-min#:y-maxy-max#:symsym#:colorcolor#:fill-colorfill-color#:x-jitterx-jitter#:y-jittery-jitter#:sizesize#:line-widthline-width#:alphaalpha#:labellabel
The optional #:discrete-color aesthetic dictates a variable to split on by color, in discrete groups.
Similarly, the #:continuous-color aesthetic dictates a continuous (numeric) variable to split on by color. You likely want to use a continuous colormap (see theme-continuous ) for this. Legends for continuous colors are not currently supported. We are working on it.
procedure
#:x-maxx-max#:y-miny-min#:y-maxy-max#:samplessamples#:colorcolor#:widthwidth#:stylestyle#:alphaalpha#:labellabel#:methodmethod#:spanspan#:degreedegree#:show-equation?show-equation?
#:width3#:label"LOESS"))
The optional #:degree argument specifies the degree of the fit line (2 for a second-degree polynomial, et cetera) in the case of the 'poly method, or the degree of each local fit in the case of 'loess.
See the documentation for loess-fit for details on the #:span parameter.
The optional #:show-equation? argument specifies whether to show the full fit equation in the legend. As LOESS is a non-parametric fit, this requires the 'poly method.
procedure
#:x-maxx-max#:y-miny-min#:y-maxy-max#:colorcolor#:widthwidth#:stylestyle#:alphaalpha#:labellabel
procedure
[ #:x-minx-min#:x-maxx-max#:y-miny-min#:y-maxy-max#:colorcolor#:line-widthline-width#:line-styleline-style#:widthwidth#:alphaalphalocal-mapping :#:ystring?
The mandatory aesthetic #:perc-error? dictates the variable in the data-frame that corresponds to percent error. The procedure df-add-derived! may be useful for adding this to a data-frame.
procedure
#:x-maxx-max#:y-miny-min#:y-maxy-max#:gapgap#:skipskip#:invert?invert?#:colorcolor#:stylestyle#:line-colorline-color#:line-widthline-width#:line-styleline-style#:alphaalpha#:labellabel#:add-ticks?add-ticks?#:far-ticks?far-ticks?#:modemode#:group-gapgroup-gap
The #:mode argument dictates whether the y-axis should be the count of observations by the x-axis ('count), or the relative frequency of those observations ('prop).
The optional #:group aesthetic dictates whether the bar should be "dodged", with each bar being broken up into bars based on the group. If this is enabled, the #:group-gap argument dictates the space between each sub-chart.
procedure
#:x-maxx-max#:y-miny-min#:y-maxy-max#:gapgap#:skipskip#:invert?invert?#:colorscolors#:stylesstyles#:line-colorsline-colors#:line-widthsline-widths#:line-stylesline-styles#:alphasalphas#:labelslabels#:add-ticks?add-ticks?#:far-ticks?far-ticks?#:modemode
The mandatory #:group aesthetic dictates what variable each bar should be broken up by.
The #:mode argument dictates whether the y-axis should be the count of observations by the x-axis ('count), or the relative frequency of those observations ('prop). 'prop does not make much sense for stacked bar charts (everything is 100% of itself), but it can be useful in some scenarios.
procedure
#:x-maxx-max#:y-miny-min#:y-maxy-max#:colorcolor#:stylestyle#:line-colorline-color#:line-widthline-width#:line-styleline-style#:alphaalpha#:labellabel#:gapgap#:baselinebaseline
The optional #:gap argument specifies the gap between each bar.
The optional #:baseline argument specifies the baseline of the "x-axis". For example, if you wanted all columns with values above 20 to be above the "x-axis", and all below 20 to be below it, you would set this to be 20.
#:title"Difference between US and OECD average life expectancies"#:x-label"Year"#:y-label"Difference (years)"#:y-min-2#:y-max2#:width600#:height400#:legend-anchor'no-legend
procedure
#:x-maxx-max#:y-miny-min#:y-maxy-max#:colorcolor#:stylestyle#:line-colorline-color#:line-widthline-width#:line-styleline-style#:alphaalpha#:labellabel#:binsbins
The argument #:bins dictates the number of bins on the x-axis.
The optional #:y aesthetic will be the average of every observation in the given x-axis bin. If not specified, this will default to the count of the number of elements in the bin. Anecdotally, if you use this, you may be better off with points or lines .
procedure
#:x-maxx-max#:y-miny-min#:y-maxy-max#:samplessamples#:colorcolor#:widthwidth#:stylestyle#:alphaalpha#:labellabel
procedure
#:iqr-scaleiqr-scale#:gapgap#:box-colorbox-color#:box-stylebox-style#:box-line-colorbox-line-color#:box-line-widthbox-line-width#:box-line-stylebox-line-style#:box-alphabox-alpha#:show-outliers?show-outliers?#:outlier-coloroutlier-color#:outlier-symoutlier-sym#:outlier-fill-coloroutlier-fill-color#:outlier-sizeoutlier-size#:outlier-line-widthoutlier-line-width#:outlier-alphaoutlier-alpha#:show-whiskers?show-whiskers?#:whiskers-colorwhiskers-color#:whiskers-widthwhiskers-width#:whiskers-stylewhiskers-style#:whiskers-alphawhiskers-alpha#:show-median?show-median?#:median-colormedian-color#:median-widthmedian-width#:median-stylemedian-style#:median-alphamedian-alpha#:mappinglocal-mapping])
The optional #:iqr-scale argument is the multiplier used to determine the lower and upper limits (IQR) and which points are considered arguments. These limits are calculated as (* iqr-scale(- Q3Q1)), where Q1 and Q3 are (respectively) the first and third quantile of the data.
plot-transform:axis-transform/caxis-ticks:ticks?
(iso8601->posix"1998-01-01")(iso8601->posix"1999-01-01")10)#:x-conviso8601->posix#:width600
procedure
( get-adjusted-ticks transform)→ticks?
transform:transform?
procedure
( only-ticks ticks)→transform?
ticks:ticks?
value
value
struct
foreground-alphabackgroundbackground-alphafont-sizefont-facefont-familypen-color-mapbrush-color-map))foreground:plot-color/cbackground:plot-color/cfont-family:font-family/c
These fields correspond to, respectively, the plot parameters plot-foreground , plot-foreground-alpha , plot-background , plot-background-alpha , plot-font-size , plot-font-face , plot-font-family , plot-pen-color-map , and plot-brush-color-map . They correspond to the same behaviors in plot .
The pen-color-map field corresponds to the color-map used to draw points and lines, such as that in points or lines . The brush-color-map field corresponds to the color-map used to draw rectangles and other large fields, such as histogram and bar .
procedure
#:fg-alphafg-alpha#:bgbg#:bg-alphabg-alpha#:font-sizefont-size#:font-facefont-face#:font-familyfont-family#:color-mapcolor-map#:brush-color-mapbrush-color-map])
procedure
[ #:fgfg#:fg-alphafg-alpha#:bgbg#:bg-alphabg-alpha#:font-sizefont-size#:font-facefont-face#:font-familyfont-family#:color-mapcolor-map#:brush-color-mapbrush-color-map])theme:graphite-theme?font-family : font-family/c
(theme-override theme-default #:font-face"Comic Sans MS")
value
#:bg"white"#:bg-alpha1#:font-size11#:font-family'swiss#:color-map'set1#:brush-color-map'pastel1)
Uses a sans-serif font, white background, black text, and the 'set1 color-map and 'pastel1 brush color map. See the documentation for plot-pen-color-map for the colors of this theme.
value
procedure
( theme->alist theme)→(listof (cons/c parameter? any/c ))
theme:graphite-theme?