I would like to create pole/zero plot similar to pole/zero plot. It is for displaying IIR and FIR filters properties like stability, type…
My question is: How can I set same scale (not range) for both axes?
I use ScatterPlot for chart.
JFreeChart chart = ChartFactory.createScatterPlot("Pole/zero plot", // chart
// title
"real", // x axis label
"imaginary", // y axis label
result, // data
PlotOrientation.VERTICAL, true, // include legend
true, // tooltips
false // urls
);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setDomainGridlinesVisible(true);
plot.setRangeGridlinesVisible(true);
plot.setRangeGridlinePaint(Color.black);
plot.setDomainGridlinePaint(Color.black);
XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
renderer.setBaseItemLabelsVisible(true);
renderer.setBaseItemLabelsVisible(true, true);
plot.setDomainCrosshairVisible(true);
plot.setDomainCrosshairLockedOnData(true);
plot.setRangeCrosshairVisible(true);
plot.setRangeCrosshairLockedOnData(true);
float dash1[] = { 10.0f };
XYShapeAnnotation unitCircle = new XYShapeAnnotation(
new Ellipse2D.Double(-1, -1, 2, 2), new BasicStroke(1.0f,
BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f,
dash1, 0.0f), Color.black);
plot.addAnnotation(unitCircle);
plot.setBackgroundPaint(Color.white);
chart.setAntiAlias(true);
chartPanel = new JPanel(new BorderLayout());
ChartPanel cp = new ChartPanel(chart);
cp.setMouseWheelEnabled(true);
cp.setToolTipText("test");
cp.setDisplayToolTips(true);
chartPanel.add(cp);
Sans legend, setting the preferred size of the
ChartPanelworks pretty well:See also Should I avoid the use of
set(Preferred|Maximum|Minimum)Size()methods in Java Swing? and this answer regarding chart size.