List of usage examples for org.jfree.chart JFreeChart getXYPlot
public XYPlot getXYPlot()
From source file:org.drugis.addis.gui.LyndOBrienChartFactory.java
public static JFreeChart buildRiskAcceptabilityCurve(LyndOBrienModel model) { XYDataset data = new AcceptabilityCurveDataset(model); JFreeChart chart = ChartFactory.createXYLineChart("Benefit-Risk Acceptability curve", "Acceptability threshold \u03BC", "Probability", data, PlotOrientation.VERTICAL, false, false, false);/*from w w w. j a v a 2 s . c o m*/ chart.getXYPlot().getRangeAxis().setRange(0, 1); return chart; }
From source file:com.javafxpert.neuralnetviz.scenario.PlotUtil.java
private static JFreeChart createChart(XYZDataset dataset, double[] mins, double[] maxs, int nPoints, XYDataset xyData) {/*from w ww . j ava2s .c o m*/ NumberAxis xAxis = new NumberAxis("X"); xAxis.setRange(mins[0], maxs[0]); NumberAxis yAxis = new NumberAxis("Y"); yAxis.setRange(mins[1], maxs[1]); XYBlockRenderer renderer = new XYBlockRenderer(); renderer.setBlockWidth((maxs[0] - mins[0]) / (nPoints - 1)); renderer.setBlockHeight((maxs[1] - mins[1]) / (nPoints - 1)); PaintScale scale = new GrayPaintScale(0, 1.0); renderer.setPaintScale(scale); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinesVisible(false); plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5)); JFreeChart chart = new JFreeChart("", plot); chart.getXYPlot().getRenderer().setSeriesVisibleInLegend(0, false); NumberAxis scaleAxis = new NumberAxis("Probability (class 0)"); scaleAxis.setAxisLinePaint(Color.white); scaleAxis.setTickMarkPaint(Color.white); scaleAxis.setTickLabelFont(new Font("Dialog", Font.PLAIN, 7)); PaintScaleLegend legend = new PaintScaleLegend(new GrayPaintScale(), scaleAxis); legend.setStripOutlineVisible(false); legend.setSubdivisionCount(20); legend.setAxisLocation(AxisLocation.BOTTOM_OR_LEFT); legend.setAxisOffset(5.0); legend.setMargin(new RectangleInsets(5, 5, 5, 5)); legend.setFrame(new BlockBorder(Color.red)); legend.setPadding(new RectangleInsets(10, 10, 10, 10)); legend.setStripWidth(10); legend.setPosition(RectangleEdge.LEFT); chart.addSubtitle(legend); ChartUtilities.applyCurrentTheme(chart); plot.setDataset(1, xyData); XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(); renderer2.setBaseLinesVisible(false); plot.setRenderer(1, renderer2); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); return chart; }
From source file:br.unicamp.cst.util.ChartViewerUtil.java
public static synchronized ChartPanel createLineXYChart(XYSeriesCollection dataset, String title, String categoryAxisLabel, String valueAxisLabel, long timeRefresh) { final JFreeChart chart = ChartFactory.createXYLineChart(title, categoryAxisLabel, valueAxisLabel, dataset, PlotOrientation.VERTICAL, true, true, false); final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.getDomainAxis().setFixedAutoRange(timeRefresh * 100); chart.setBackgroundPaint(Color.lightGray); ChartPanel localChartPanel = new ChartPanel(chart); localChartPanel.setVisible(true);/*from ww w.ja va 2 s. co m*/ localChartPanel.setDomainZoomable(true); return localChartPanel; }
From source file:ChartPanelMaker.java
public static ChartPanel createChart(ArrayList<Voter> voters, ArrayList<Candidate> candidates, ArrayList<Candidate> committee, String title) { XYSeriesCollection dataset = new XYSeriesCollection(); XYSeries comitteeDataset = new XYSeries("Committee"); for (Candidate c : committee) { comitteeDataset.add(c.getX(), c.getY()); }//from www . j a va2 s . c om dataset.addSeries(comitteeDataset); int n = voters.size(); int m = candidates.size(); int skipN = n / 150; if (skipN < 1) { skipN = 1; } int skipM = m / 150; if (skipM < 1) { skipM = 1; } Collections.sort(voters, Election.VoterNameComparator); Collections.sort(candidates, Election.CandidateNameComparator); XYSeries voterDataset = new XYSeries("Voters"); for (int i = 0; i < n; i++) { Voter v = voters.get(i); if (i % skipN == 0) { voterDataset.add(v.getX(), v.getY()); } } dataset.addSeries(voterDataset); XYSeries candidateDataset = new XYSeries("Candidates"); for (int i = 0; i < m; i++) { Candidate c = candidates.get(i); if (i % skipM == 0) { candidateDataset.add(c.getX(), c.getY()); } } dataset.addSeries(candidateDataset); Shape committeeShape = ShapeUtilities.createDiamond(5); Shape voterShape = ShapeUtilities.createDownTriangle(3); Shape candidateShape = ShapeUtilities.createUpTriangle(3); Color committeeColor = Color.DARK_GRAY; Color voterColor = Color.ORANGE; Color candidateColor = Color.LIGHT_GRAY; JFreeChart chart = ChartFactory.createScatterPlot(title, "", "", dataset, PlotOrientation.VERTICAL, true, true, true); XYPlot plot = chart.getXYPlot(); XYItemRenderer r = plot.getRenderer(); r.setSeriesShape(0, committeeShape); r.setSeriesPaint(0, committeeColor); r.setSeriesShape(1, voterShape); r.setSeriesPaint(1, voterColor); r.setSeriesShape(2, candidateShape); r.setSeriesPaint(2, candidateColor); ChartPanel chartPanel = new ChartPanel(chart); return chartPanel; }
From source file:statistic.graph.gui.Charts.java
public static JFreeChart createXYAreaChart(DiagramData data, XYDataset dataset) { JFreeChart chart = ChartFactory.createXYAreaChart(data.getTitle(), data.getXAxisLabel(), data.getYAxisLabel(), dataset, PlotOrientation.VERTICAL, true, true, false); initXAxis(chart.getXYPlot(), dataset); return chart; }
From source file:statistic.graph.gui.Charts.java
public static JFreeChart createXYLineChart(DiagramData data, XYDataset dataset) { JFreeChart chart = ChartFactory.createXYLineChart(data.getTitle(), data.getXAxisLabel(), data.getYAxisLabel(), dataset, PlotOrientation.VERTICAL, true, true, false); initXAxis(chart.getXYPlot(), dataset); return chart; }
From source file:statistic.graph.gui.Charts.java
public static JFreeChart createXYStepChart(DiagramData data, XYDataset dataset) { JFreeChart chart = ChartFactory.createXYStepChart(data.getTitle(), data.getXAxisLabel(), data.getYAxisLabel(), dataset, PlotOrientation.VERTICAL, true, true, false); initXAxis(chart.getXYPlot(), dataset); return chart; }
From source file:org.drugis.addis.gui.LyndOBrienChartFactory.java
public static JFreeChart buildScatterPlot(LyndOBrienModel model) { XYDataset data = new ScatterPlotDataset(model); JFreeChart chart = ChartFactory.createScatterPlot("Benefit-Risk plane", model.getXAxisName(), model.getYAxisName(), data, PlotOrientation.VERTICAL, false, false, false); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) chart.getXYPlot().getRenderer(); renderer.setSeriesOutlinePaint(0, Color.black); renderer.setUseOutlinePaint(true);//w ww.j a v a 2 s . com renderer.setSeriesShape(0, new Ellipse2D.Double(-2.0, 2.0, 4.0, 4.0)); // draw lines through origin. chart.getXYPlot().setDomainZeroBaselineVisible(true); chart.getXYPlot().setRangeZeroBaselineVisible(true); // Explicitly set the stroke-width to avoid a rendering error in Linux Stroke stroke = new BasicStroke(1.0f); chart.getXYPlot().setDomainZeroBaselineStroke(stroke); return chart; }
From source file:statistic.graph.gui.Charts.java
public static JFreeChart createXYStepAreaChart(DiagramData data, XYDataset dataset) { JFreeChart chart = ChartFactory.createXYStepAreaChart(data.getTitle(), data.getXAxisLabel(), data.getYAxisLabel(), dataset, PlotOrientation.VERTICAL, true, true, false); initXAxis(chart.getXYPlot(), dataset); return chart; }
From source file:statistic.graph.gui.Charts.java
public static JFreeChart createXYBarChart(DiagramData data, IntervalXYDataset dataset) { JFreeChart chart = ChartFactory.createXYBarChart(data.getTitle(), data.getXAxisLabel(), false, data.getYAxisLabel(), dataset, PlotOrientation.VERTICAL, true, true, false); initXAxis(chart.getXYPlot(), dataset); return chart; }