List of usage examples for org.jfree.chart.renderer.xy XYLineAndShapeRenderer setShapesVisible
public void setShapesVisible(boolean visible)
From source file:com.joey.software.plottingToolkit.PlotingToolkit.java
public static JFreeChart getPlot(double[] xData, double[] yData, String title, String xlabel, String ylabel) { XYSeriesCollection datCol = getCollection(xData, yData, "Data"); // Create the chart JFreeChart chart = ChartFactory.createXYLineChart(title, // Title xlabel, // X-Axis label ylabel, // Y-Axis label new XYSeriesCollection(), // Dataset PlotOrientation.VERTICAL, true, // Show legend true, true);// w ww. j av a 2 s. co m // Add the series chart.getXYPlot().setDataset(0, datCol); // Set the rendering XYLineAndShapeRenderer rend1 = new XYLineAndShapeRenderer(true, true); rend1.setShapesVisible(false); chart.getXYPlot().setRenderer(0, rend1); return chart; }
From source file:ca.nengo.plot.impl.DefaultPlotter.java
private static void configSpikeRenderer(XYLineAndShapeRenderer renderer) { renderer.setShape(ShapeUtilities.createDiamond(1f)); renderer.setShapesVisible(true); renderer.setShapesFilled(true);/*from w ww .j a v a 2s. c om*/ renderer.setLinesVisible(false); renderer.setPaint(Color.BLACK); }
From source file:br.unicamp.cst.behavior.bn.support.Grafico.java
public Grafico(String frametitle, String charttitle, String xlabel, String ylabel, XYSeriesCollection dataset) { JFreeChart chart = ChartFactory.createXYLineChart(charttitle, xlabel, ylabel, dataset, PlotOrientation.VERTICAL, true, true, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setShapesVisible(true); renderer.setShapesFilled(true);/* w w w . j av a2s .c o m*/ setXyplot(plot); setChart(chart); ChartFrame frame = new ChartFrame(frametitle, chart); frame.pack(); frame.setVisible(true); }
From source file:org.pentaho.plugin.jfreereport.reportcharts.XYLineChartExpression.java
protected void configureChart(final JFreeChart chart) { super.configureChart(chart); final XYPlot xypl = chart.getXYPlot(); final XYItemRenderer renderer = xypl.getRenderer(); renderer.setStroke(translateLineStyle(lineWidth, lineStyle)); if (renderer instanceof XYLineAndShapeRenderer) { final XYLineAndShapeRenderer renderer1 = (XYLineAndShapeRenderer) renderer; renderer1.setShapesVisible(isMarkersVisible()); renderer1.setBaseShapesFilled(isMarkersVisible()); }//from ww w .j av a 2 s.c o m }
From source file:edu.wustl.cab2b.client.ui.visualization.charts.LineChart.java
protected JFreeChart createChart(Dataset dataset) { XYDataset xyDataset = (XYDataset) dataset; JFreeChart jfreechart = ChartFactory.createXYLineChart("Line Chart", "X", "Y", xyDataset, PlotOrientation.VERTICAL, true, true, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setBackgroundPaint(Color.white); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer(); xylineandshaperenderer.setShapesVisible(true); xylineandshaperenderer.setShapesFilled(true); NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return jfreechart; }
From source file:sanger.team16.gui.genevar.eqtl.snp.RegionalLinePlot.java
private JFreeChart createChart(String chromosome, int position, int distance, double threshold, XYDataset dataset) {/*from w ww .j a v a2 s . c om*/ JFreeChart chart = ChartFactory.createXYLineChart(null, "Position on chromosome " + chromosome + " (bp)", "-log10(P)", dataset, PlotOrientation.VERTICAL, true, true, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinePaint(Color.lightGray); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setShapesVisible(true); //renderer.setShapesFilled(false); //CHANGED 12/12/11 // change the auto tick unit selection to integer units only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); /* XYItemRenderer renderer = plot.getRenderer(); int size = dataset.getSeriesCount(); for (int i=0 ; i<size ; i++) { //renderer.setSeriesPaint(i, new Color(255, 0, 0)); renderer.setSeriesShape(i, ShapeUtilities.createDiamond((float) 3)); renderer.setBaseSeriesVisibleInLegend(false); } */ ValueMarker upperMarker = new ValueMarker(-Math.log10(threshold)); upperMarker.setPaint(Color.gray); float[] f = { 4, 3, 4, 3 }; upperMarker.setStroke(new BasicStroke(1.0f, 1, 1, 0, f, 1.0f)); plot.addRangeMarker(upperMarker); ValueMarker marker = new ValueMarker(0.0); marker.setPaint(Color.lightGray); plot.addRangeMarker(marker); XYSeries series = new XYSeries("Range"); series.add(position - distance, -0.05); series.add(position + distance, -0.05); ((XYSeriesCollection) dataset).addSeries(series); renderer.setSeriesVisible(dataset.getSeriesCount() - 1, false, false); return chart; }
From source file:view.FuzzySetView.java
private void setupRenderer() { XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setShapesVisible(false); plot = getChart().getXYPlot();//from ww w . j a v a2 s . c o m int termCount = plot.getSeriesCount(); for (int i = 0; i < termCount; i++) { renderer.setSeriesPaint(i, colors[i]); } BasicStroke stroke = new BasicStroke(3f); for (int i = 0; i < termCount; i++) { renderer.setSeriesStroke(i, stroke); } plot.setRenderer(renderer); setupPlotAxes(); }
From source file:flexflux.analyses.result.ParetoAnalysisResult.java
public void plot() { XYSeriesCollection dataset = new XYSeriesCollection(); int i = 1;/*from www.ja v a 2s . c o m*/ for (Objective obj : oneDResults.keySet()) { XYSeries series = new XYSeries(obj.getName()); for (double val : oneDResults.get(obj)) { series.add(i, val); } dataset.addSeries(series); i++; } // create the chart... final JFreeChart chart = ChartFactory.createXYLineChart("", // chart title "Objectives", // x axis label "Values", // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); ChartPanel chartPanel = new ChartPanel(chart); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setRangeGridlinePaint(Color.GRAY); plot.setDomainGridlinePaint(Color.GRAY); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setLinesVisible(false); renderer.setShapesVisible(true); plot.setRenderer(renderer); // change the auto tick unit selection to integer units only... NumberAxis rangeAxis = (NumberAxis) plot.getDomainAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); JFrame frame = new JFrame("Pareto analysis one dimension results"); frame.add(chartPanel); frame.pack(); RefineryUtilities.centerFrameOnScreen(frame); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.setVisible(true); for (PP2DResult r : twoDResults.keySet()) { r.plot(); } for (PP3DResult r : threeDResults.keySet()) { r.plot(); } }
From source file:org.matsim.counts.algorithms.graphs.CountsSimRealPerHourGraph.java
/** * @param hour A value in 1..24, 1 for 0 a.m. to 1 a.m., 2 for 1 a.m. to 2 a.m. ... *//*from w ww. ja va 2 s.co m*/ @Override public JFreeChart createChart(final int hour) { this.hour = hour; XYSeriesCollection dataset0 = new XYSeriesCollection(); XYSeries series = new XYSeries("MATSim volumes"); // easier to use another dataset XYSeriesCollection dataset_outliers = new XYSeriesCollection(); XYSeries series_outliers = new XYSeries("MATSim outliers"); CustomXYURLGenerator url_gen = new CustomXYURLGenerator(); CustomXYToolTipGenerator tt_gen = new CustomXYToolTipGenerator(); final ArrayList<String> urls = new ArrayList<String>(); final ArrayList<String> tooltips = new ArrayList<String>(); List<Comp> comps = new Vector<Comp>(); Iterator<CountSimComparison> l_it = this.ccl_.iterator(); //int elementCounter=0; while (l_it.hasNext()) { CountSimComparison cc = l_it.next(); /* values with simVal==0.0 or countVal==0.0 are drawn on the x==1 or/and y==1-line * Such values are the result of a poor simulation run, but they can also represent * a valid result (closing summer road during winter time) * */ if (cc.getHour() == hour) { //elementCounter++; double realVal = 1.0; double simVal = 1.0; if (cc.getCountValue() > 0.0 && cc.getSimulationValue() > 0.0) { realVal = cc.getCountValue(); simVal = cc.getSimulationValue(); series.add(realVal, simVal); comps.add(new Comp(realVal, "link" + cc.getId() + ".html", "Link " + cc.getId() + "; " + "Count: " + realVal + ", Sim: " + simVal)); } else { realVal = Math.max(1.0, cc.getCountValue()); simVal = Math.max(1.0, cc.getSimulationValue()); series_outliers.add(realVal, simVal); } } //if } //while dataset0.addSeries(series); dataset_outliers.addSeries(series_outliers); /* first we have to sort the vector according to the rendering ordering * (which is the x value). * REALLY??? After hours of searching no better solution found! * please help! */ Collections.sort(comps, new MyComparator()); for (Iterator<Comp> iter = comps.iterator(); iter.hasNext();) { Comp cp = iter.next(); urls.add(cp.getURL()); tooltips.add(cp.getTooltip()); } url_gen.addURLSeries(urls); tt_gen.addToolTipSeries(tooltips); String title = "Volumes " + (hour - 1) + ":00 - " + (hour) + ":00, Iteration: " + this.iteration_; this.setChartTitle(title); this.chart_ = ChartFactory.createXYLineChart(title, "Count Volumes [veh/h]", // x axis label "Sim Volumes [veh/h]", // y axis label dataset0, // data PlotOrientation.VERTICAL, false, // include legend true, // tooltips true // urls ); XYPlot plot = this.chart_.getXYPlot(); final LogarithmicAxis axis_x = new LogarithmicAxis("Count Volumes [veh/h]"); final LogarithmicAxis axis_y = new LogarithmicAxis("Sim Volumes [veh/h]"); axis_x.setAllowNegativesFlag(false); axis_y.setAllowNegativesFlag(false); //regular values XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setLinesVisible(false); renderer.setURLGenerator(url_gen); renderer.setSeriesPaint(0, Color.black); renderer.setSeriesToolTipGenerator(0, tt_gen); renderer.setSeriesShape(0, new Rectangle2D.Double(-1.5, -1.5, 3.0, 3.0)); //outliers XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(); renderer2.setLinesVisible(false); renderer2.setSeriesPaint(0, Color.red); renderer2.setSeriesShape(0, new Ellipse2D.Double(-3.0, -3.0, 6.0, 6.0)); // error band DefaultXYDataset dataset1 = new DefaultXYDataset(); dataset1.addSeries("f1x", new double[][] { { 1.0, 10000.0 }, { 1.0, 10000.0 } }); dataset1.addSeries("f2x", new double[][] { { 1.0, 10000.0 }, { 2.0, 20000.0 } }); dataset1.addSeries("f05x", new double[][] { { 2.0, 10000.0 }, { 1.0, 5000.0 } }); XYLineAndShapeRenderer renderer3 = new XYLineAndShapeRenderer(); renderer3.setShapesVisible(false); renderer3.setSeriesPaint(0, Color.blue); renderer3.setSeriesPaint(1, Color.blue); renderer3.setSeriesPaint(2, Color.blue); renderer3.setBaseSeriesVisibleInLegend(false); renderer3.setSeriesItemLabelsVisible(0, true); renderer3.setSeriesItemLabelsVisible(1, false); renderer3.setSeriesItemLabelsVisible(2, false); XYTextAnnotation annotation0 = new XYTextAnnotation("2.0 count", 12000.0, 15500.0); annotation0.setFont(new Font("SansSerif", Font.BOLD, 11)); plot.addAnnotation(annotation0); XYTextAnnotation annotation1 = new XYTextAnnotation("count", 13000.0, 10000.0); annotation1.setFont(new Font("SansSerif", Font.BOLD, 11)); plot.addAnnotation(annotation1); XYTextAnnotation annotation2 = new XYTextAnnotation("0.5 count", 11000.0, 3500.0); annotation2.setFont(new Font("SansSerif", Font.BOLD, 11)); plot.addAnnotation(annotation2); plot.setDomainAxis(axis_x); plot.setRangeAxis(axis_y); plot.setRenderer(0, renderer); plot.setRenderer(1, renderer2); plot.setDataset(1, dataset_outliers); plot.setRenderer(2, renderer3); plot.setDataset(2, dataset1); plot.getRangeAxis().setRange(1.0, 19000.0); plot.getDomainAxis().setRange(1.0, 19000.0); return this.chart_; }
From source file:org.matsim.counts.algorithms.graphs.CountsSimReal24Graph.java
@Override public JFreeChart createChart(final int nbr) { XYSeriesCollection dataset0 = new XYSeriesCollection(); XYSeries series = new XYSeries("MATSim volumes"); // easier to use another dataset XYSeriesCollection dataset_outliers = new XYSeriesCollection(); XYSeries series_outliers = new XYSeries("MATSim outliers"); CustomXYURLGenerator url_gen = new CustomXYURLGenerator(); CustomXYToolTipGenerator tt_gen = new CustomXYToolTipGenerator(); final ArrayList<String> urls = new ArrayList<>(); final ArrayList<String> tooltips = new ArrayList<>(); List<Comp> comps = new Vector<>(); //-------------------- CountSimComparisonLinkFilter linkFilter = new CountSimComparisonLinkFilter(this.ccl_); final Vector<Id<Link>> linkIds = new CountSimComparisonLinkFilter(this.ccl_).getLinkIds(); Iterator<Id<Link>> id_it = linkIds.iterator(); double maxCountValue = 0.1; double maxSimValue = 0.1; // yyyy PtCountsKMLWriterTest.testPtAlightKMLCreation never touches these and then leads to an exception later // when they are zero. Don't know why. kai, sep'16 while (id_it.hasNext()) { Id<Link> id = id_it.next(); double countVal = linkFilter.getAggregatedCountValue(id); double simVal = linkFilter.getAggregatedSimValue(id); if (countVal > 100.0 && simVal > 100.0) { if (countVal > maxCountValue) maxCountValue = countVal; if (simVal > maxSimValue) maxSimValue = simVal;//from w ww . j av a 2 s . com series.add(countVal, simVal); comps.add(new Comp(countVal, "link" + id + ".html", "Link " + id + "; " + "Count: " + countVal + ", Sim: " + simVal)); } else { /* values with simVal<100.0 or countVal<100.0 are drawn on the x==100 or/and y==100-line */ countVal = Math.max(100.0, countVal); simVal = Math.max(100.0, simVal); series_outliers.add(countVal, simVal); if (countVal > maxCountValue) maxCountValue = countVal; if (simVal > maxSimValue) maxSimValue = simVal; } } //while dataset0.addSeries(series); dataset_outliers.addSeries(series_outliers); Collections.sort(comps, new MyComparator()); for (Iterator<Comp> iter = comps.iterator(); iter.hasNext();) { Comp cp = iter.next(); urls.add(cp.getURL()); tooltips.add(cp.getTooltip()); } url_gen.addURLSeries(urls); tt_gen.addToolTipSeries(tooltips); String title = "Avg. Weekday Traffic Volumes, Iteration: " + this.iteration_; this.setChartTitle(title); this.chart_ = ChartFactory.createXYLineChart(title, "Count Volumes", // x axis label "Sim Volumes", // y axis label dataset0, // data PlotOrientation.VERTICAL, false, // include legend true, // tooltips true // urls ); XYPlot plot = this.chart_.getXYPlot(); final LogarithmicAxis axis_x = new LogarithmicAxis("Count Volumes [veh/24h]"); final LogarithmicAxis axis_y = new LogarithmicAxis("Sim Volumes [veh/24h]"); axis_x.setAllowNegativesFlag(false); axis_y.setAllowNegativesFlag(false); //regular values XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setLinesVisible(false); renderer.setURLGenerator(url_gen); renderer.setSeriesPaint(0, Color.black); renderer.setSeriesToolTipGenerator(0, tt_gen); renderer.setSeriesShape(0, new Rectangle2D.Double(-1.5, -1.5, 3.0, 3.0)); //outliers XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(); renderer2.setLinesVisible(false); renderer2.setSeriesPaint(0, Color.red); renderer2.setSeriesShape(0, new Ellipse2D.Double(-3.0, -3.0, 6.0, 6.0)); // error band DefaultXYDataset dataset1 = new DefaultXYDataset(); Gbl.assertIf(maxCountValue > 0.); dataset1.addSeries("f1x", new double[][] { { 100.0, maxCountValue }, { 100.0, maxCountValue } }); dataset1.addSeries("f2x", new double[][] { { 100.0, maxCountValue }, { 200.0, 2 * maxCountValue } }); dataset1.addSeries("f05x", new double[][] { { 200.0, maxCountValue }, { 100.0, 0.5 * maxCountValue } }); XYLineAndShapeRenderer renderer3 = new XYLineAndShapeRenderer(); renderer3.setShapesVisible(false); renderer3.setSeriesPaint(0, Color.blue); renderer3.setSeriesPaint(1, Color.blue); renderer3.setSeriesPaint(2, Color.blue); renderer3.setBaseSeriesVisibleInLegend(false); renderer3.setSeriesItemLabelsVisible(0, true); renderer3.setSeriesItemLabelsVisible(1, false); renderer3.setSeriesItemLabelsVisible(2, false); XYTextAnnotation annotation0 = new XYTextAnnotation("2.0 count", maxCountValue, 2 * maxCountValue); annotation0.setFont(new Font("SansSerif", Font.BOLD, 11)); plot.addAnnotation(annotation0); XYTextAnnotation annotation1 = new XYTextAnnotation("count", maxCountValue, maxCountValue); annotation1.setFont(new Font("SansSerif", Font.BOLD, 11)); plot.addAnnotation(annotation1); XYTextAnnotation annotation2 = new XYTextAnnotation("0.5 count", maxCountValue, 0.5 * maxCountValue); annotation2.setFont(new Font("SansSerif", Font.BOLD, 11)); plot.addAnnotation(annotation2); plot.setDomainAxis(axis_x); plot.setRangeAxis(axis_y); plot.setRenderer(0, renderer); plot.setRenderer(1, renderer2); plot.setDataset(1, dataset_outliers); plot.setRenderer(2, renderer3); plot.setDataset(2, dataset1); //plot.getRangeAxis().setRange(1.0, 19000.0); //plot.getDomainAxis().setRange(1.0, 19000.0); return this.chart_; }