Graphics Reference
In-Depth Information
plotModel.drawString(String.valueOf(dataModel.getMax(i)),
0.5, 0.9, DrawString.CENTER, null);
plotModel.setXAxisLabel(plotModel.getYAxisLabel());
plotModel.setDrawYAxisLabel(false);
plotModel.setDrawFrame(false);
plotModel.setDrawXZeroLine(true);
multiPlotModel.setPlotModel(plotModel);
}
We generate a MultiPlotModel object for a DataModel object specified by
dataModel .Wedivide tinto
(number of variables) regions. he
setConnect(true) method of the MultiPlotModel class enables usto con-
nect the points for the same observation. setSelector(new Line-
Selector()) specifiestheuseofa LineSelector object.Inthenext for com-
mand,weplacescatterplots generated bythe new ScatterPlotModel(data-
Model, PlotModel.NULL, i) method for each variable. We specify that no
data are available for the x-axis, and the i -th variable of dataModel is used as
dataforthe y-axis.hemethods setDrawXTick(false) and setDrawYTick
(false) specify that the x-andy-axes are not drawn. Next, several lines set and
draw the maximum values of the variables at the top of the y-axis and the minimum
valuesatthebottom.he setXAxisLabel(plotModel.getYAxisLabel())
method drawsavariable name given for the y-axisattheplacewherethelabelforthe
x-axisisdrawn. setDrawYAxisLabel(false) does not draw a variable name
forthe y-axis, setDrawFrame(false) doesnotdrawaframeforthescatterplot,
and setDrawXZeroLine(true) draws a line at the position of the x-axis. We
do not set the location in the setPlotModel(plotModel) method, because
graphics are automatically placed from let to right when they are not given.
histypeofparallelcoordinateplotusuallybecomeslonghorizontally.Inthiscase,
it may be useful to attach a JasplotPanel object to a JScrollPane object of
Swing,whichhasascrollbarandcanshowapartofthewholegraphicinthewindow.
We can attach these MultiPlotModel classes to a MultiPlotModel class
recursively. For example, Fig. . shows a scatterplot matrix and a parallel coordi-
nate plot on a MultiPlotModel object.
Concluding Remarks
17.4
By following design patterns, Java statistical graphics programming is made exten-
sible and reusable. Such patterns are useful for building new graphics from existing
components inthelibrary.Weillustrate theusefulnessofthesesolutions with Jasplot,
a Java statistical graphics library.
Note that we did not use all of the GoF design patterns to build Jasplot. We
should not use design patterns excessively in a project; this would impact negatively
on the simplicity and execution speed of the program. However, it is a good idea to
use design patterns appropriately. If it is possible to use design patterns with a little
Search WWH ::




Custom Search