Changing the shapes of points in scatter plot

A ScatterRenderer inherits getItemShape() from AbstractRenderer. You can override getItemShape() to supply your own shapes. Addendum: One advantage to this approach is that you can specify a Shape for each item in each series. Addendum: To use ShapeUtilities.createDiagonalCross(), do something like this: Shape cross = ShapeUtilities.createDiagonalCross(3, 1); plot = (XYPlot) chart.getPlot(); renderer = plot.getRenderer(); renderer.setSeriesShape(0, … Read more

JFreeChart scaling of Boxplots with several Categories

Set the preferred size of the containing ChartPanel, not the chart, as shown here and here. Addendum: I don’t think you can usefully add a chart to a scroll pane. Instead, create a class similar to SlidingCategoryDataset that implements BoxAndWhiskerCategoryDataset. Add a scroll bar to the frame that controls the first displayed index. Addendum: A … Read more

CombinedDomainXYPlot not rescaling domain axis

CombinedDomainXYPlot establishes the combined maximal Range for its shared domain axis in getDataRange(). This is required to allow the axis to be shared. Changing the visibility of a series has no effect on the shared domain axis; changing the Dataset updates the shared domain axis via its configure() method. In either case, the subplots’ range … Read more

How do I change a JFreeChart’s size

When you create your ChartPanel, you have several options that affect the result: Accept the DEFAULT_WIDTH and DEFAULT_HEIGHT: 680 x 420. Specify the preferred width and height in the constructor. Invoke setPreferredSize() explicitly if appropriate. Override getPreferredSize() to calculate the size dynamically. @Override public Dimension getPreferredSize() { // given some values of w & h … Read more

Random errors when changing series using JFreeChart

Your snippet is incorrectly synchronized; you should update your dataset from the process() method of a SwingWorker, as shown here. Because your domain is “the number of my inner iterations”, don’t use a DateAxis; instead, use a NumberAxis, as shown in ChartFactory.createXYLineChart(). Addendum: This variation on the example plots the worker’s progress on a line … Read more

How can I update a JFreeChart’s appearance after it’s been made visible?

The class ChartPanel is convenient for this, as it has methods to control the chart’s overall appearance, including properties and zoom state. In addition it’s also possible to access the chart’s components, as shown below. This related example illustrates a JToolBar of zoom buttons. import java.awt.BorderLayout; import java.awt.EventQueue; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import … Read more