我在散点图上有成千上万的点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, true, false); Shape cross = ShapeUtilities.createDiagonalCross(3, 1); XYPlot xyPlot = (XYPlot) jfreechart.getPlot(); XYItemRenderer renderer = xyPlot.getRenderer(); renderer.setBaseShape(cross); renderer.setBasePaint(Color.red); //changing the Renderer to XYDotRenderer //xyPlot.setRenderer(new XYDotRenderer()); XYDotRenderer xydotrenderer = new XYDotRenderer(); xyPlot.setRenderer(xydotrenderer); xydotrenderer.setSeriesShape(0, cross); xyPlot.setDomainCrosshairVisible(true); xyPlot.setRangeCrosshairVisible(true); return new ChartPanel(jfreechart); }
更改散点图中的点的形状
相关分类