Database Reference
In-Depth Information
How it works...
The
incanter.charts/scatter-plot
function takes two sequences, one of the points'
x
coordinates and one of their
y
coordinates.
By default, Incanter labels the x- and y-axes from the expressions we use in the call to
scatter-plot
. In this case, that would be
(i/sel race-data :cols :Petal.Width)
for the x-axis and
(i/sel race-data :cols :Petal.Length)
for the y-axis. That's not
very readable, so we specify the axes' labels with the
:x-label
and
:y-label
parameters.
However, the
scatter-plot
function only creates the chart object. To view it, we have to
pass it to the
incanter.core/view
function.
If we right-click on a displayed graph, several other options show up as well. From the
context menu, we can zoom in and out, print the chart, and change the labels. The charts
are also interactive. Clicking and dragging on the graph zooms the view into focus on the
area we selected.
There's more...
F
The Incanter API documentation that lists the supported charts and the options for
See also
We'll see how to save graphs in the
Saving Incanter graphs to PNG
recipe.
Graphing non-numeric data in bar charts
Not everything is numeric, and often non-numeric data has to be handled differently, as we
saw in the chapter on statistics and the chapter on data mining. For example, a scatter plot
doesn't make much sense unless the data is naturally ordered in some way.
In this recipe, we'll use a bar chart to display how many items have a possible value each for a
ield of categorical data.