我在JFreeChart散点图上绘制了数千个点.现在的问题是我的程序正在用"正方形"绘制点,但我需要一些帮助来解决如何将Shape点从"正方形"更改为"点/圆"的问题.任何帮助,将不胜感激.
// *我正在使用ShapeUtilities,但是当我使用XYItemRenderer/XYDotRenderer时,它没有改变指向"DaigonalCross"的形状 - 如果代码中有任何错误,请更正.* ///
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Shape;
import java.util.*;
import javax.swing.JPanel;
import org.jfree.chart.*;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.xy.XYItemRenderer;
import org.jfree.chart.renderer.xy.XYDotRenderer;
import org.jfree.data.xy.XYDataset;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;
import org.jfree.util.ShapeUtilities;
public class SPlotfinal extends ApplicationFrame {
public SPlotfinal(String s) {
super(s);
JPanel jpanel = createDemoPanel();
jpanel.setPreferredSize(new Dimension(500, 270));
setContentPane(jpanel);
}
public static JPanel createDemoPanel() {
JFreeChart jfreechart = ChartFactory.createScatterPlot("Scatter Plot Demo",
"X", "Y", samplexydataset2(), PlotOrientation.VERTICAL, true, …Run Code Online (Sandbox Code Playgroud)
我想创建类似极点/零点的极点/零点图.它用于显示IIR和FIR滤波器属性,如稳定性,类型......
我的问题是:如何为两个轴设置相同的比例(不是范围)?
我使用ScatterPlot作为图表.
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, …Run Code Online (Sandbox Code Playgroud)