Database Reference
In-Depth Information
How it works...
The object returned by the Incanter chart functions is the JFreeChart object. This is the
builder class for all the charts. From this object, we can access the plot objects, which provide
interfaces for different types of charts, and from the plot objects, we can access options such
as axes, annotations, colors, and renderers, which handle the actual drawing of the chart.
That's what we do in this recipe. The relevant code snippet is as follows:
(doto (.getPlot iris-dimensions)
(.setRenderer (doto (LayeredBarRenderer.)
(.setDrawBarOutline false)))
(.setRowRenderingOrder SortOrder/DESCENDING))
In this code, we get the plot, set the renderer to an instance of LayeredBarRenderer ,
and then change the order of row rendering. If we don't do that, then the shorter rows get
rendered behind the taller ones, which isn't useful.
See also
F The class hierarchy for this is quite complex and fully featured. To get a good feel
for its breadth and for what the library is capable of, browse the Java docs for it at
http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/
JFreeChart.html .
F If you plan on using JFreeChart a lot, the developer guide at http://www.jfree.
org/jfreechart/devguide.html may be a good investment.
Customizing chart colors and styles
In the last recipe, we customized the type of chart and how the data is displayed and laid out.
However, we'll often want to customize other things, such as the chart's color scheme or style.
In this recipe, we'll take a chart that we created for another recipe and change the way it
looks. This will give an example of how to customize the color and other parts of how the
chart displays.
Getting ready
We'll use the same dependencies in our project.clj ile as we did in Creating scatter plots
with Incanter , and this set of imports in our script or REPL:
(require '[incanter.core :as i]
'[incanter.charts :as c]
'[incanter.io :as iio]
'[incanter.stats :as s])
 
Search WWH ::




Custom Search