List of usage examples for org.jfree.chart.renderer.xy XYLineAndShapeRenderer setSeriesLinesVisible
public void setSeriesLinesVisible(int series, boolean visible)
From source file:edu.ucla.stat.SOCR.chart.demo.QQData2DataDemo.java
/** * Creates a chart.// w w w. j a va 2 s.c o m * * @param dataset the data for the chart. * * @return a chart. */ protected JFreeChart createChart(XYDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, //"Data vs Data Q-Q plot", // chart title domainLabel, // x axis label rangeLabel, // y axis label dataset, // data PlotOrientation.VERTICAL, !legendPanelOn, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); // renderer.setShapesVisible(true); renderer.setBaseShapesFilled(true); // renderer.setLinesVisible(false); renderer.setSeriesLinesVisible(1, true); renderer.setSeriesShapesVisible(1, false); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesShapesVisible(0, true); //renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator()); // change the auto tick unit selection to integer units only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setAutoRangeIncludesZero(false); rangeAxis.setUpperMargin(0.02); rangeAxis.setLowerMargin(0.02); // rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setAutoRangeIncludesZero(false); domainAxis.setUpperMargin(0.02); domainAxis.setLowerMargin(0.02); // domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // OPTIONAL CUSTOMISATION COMPLETED. setQQSummary(dataset); return chart; }
From source file:no.ntnu.mmfplanner.ui.graph.SaNpvChart.java
/** * Creates the chart/*from ww w .j a v a2 s. c om*/ */ private void createChart() { JFreeChart chart = ChartFactory.createXYLineChart(null, // chart title "Period", // x axis label "Discounted Cash", // y axis label null, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); XYPlot plot = (XYPlot) chart.getPlot(); plot.getDomainAxis().setLowerMargin(0.0); plot.getDomainAxis().setUpperMargin(0.0); plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_LEFT); // change the auto tick unit selection to integer units only... NumberAxis rangeAxis = (NumberAxis) plot.getDomainAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); setChart(chart); setMouseZoomable(false); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setLegendLine(new Rectangle2D.Double(0.0, 0.0, 6.0, 0.0)); renderer.setUseFillPaint(true); // the x=0 line renderer.setSeriesPaint(0, Color.GRAY); renderer.setSeriesShapesVisible(0, false); renderer.setSeriesLinesVisible(0, true); renderer.setSeriesVisibleInLegend(0, new Boolean(false)); plot.setRenderer(renderer); }
From source file:ui.Graph.java
/** * Creates a chart.//from w w w. j a v a 2s . c o m * * @param dataset * the data for the chart. * * @return a chart. */ private JFreeChart createChart(ArrayList<Setpoint> setpoints, ArrayList<Setpoint> traj) { trajectory = traj; XYSeries posSeries = new XYSeries("Position"); XYSeries trajSeries = new XYSeries("Trajectory"); XYSeries velSeries = new XYSeries("Velocity"); for (int i = 0; i < setpoints.size(); i++) { Setpoint p = setpoints.get(i); posSeries.add(p.time, p.position); velSeries.add(p.time, p.velocity); } for (int i = 0; i < trajectory.size(); i++) { Setpoint p = trajectory.get(i); trajSeries.add(p.time, p.position); } XYSeriesCollection posDataset = new XYSeriesCollection(); XYSeriesCollection trajDataset = new XYSeriesCollection(); XYSeriesCollection velDataset = new XYSeriesCollection(); posDataset.addSeries(posSeries); velDataset.addSeries(velSeries); trajDataset.addSeries(trajSeries); // create the chart... final JFreeChart chart = ChartFactory.createScatterPlot("System output", // chart title "X", // x axis label "Y", // y axis label posDataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); // final StandardLegend legend = (StandardLegend) chart.getLegend(); // legend.setDisplaySeriesShapes(true); // get a reference to the plot for further customisation... final XYPlot plot = chart.getXYPlot(); plot.setDataset(0, posDataset); plot.setDataset(1, trajDataset); plot.setDataset(2, velDataset); plot.setBackgroundPaint(Color.white); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); XYLineAndShapeRenderer posRenderer = new XYLineAndShapeRenderer(); // renderer.setSeriesShape(0, new Ellipse2D.Float(1.0f, 1.0f, 1.0f, // 1.0f)); posRenderer.setSeriesPaint(0, Color.BLUE); posRenderer.setSeriesLinesVisible(0, true); posRenderer.setSeriesShapesVisible(0, false); XYStepRenderer trajRenderer = new XYStepRenderer(); trajRenderer.setSeriesPaint(1, Color.RED); trajRenderer.setSeriesStroke(1, new BasicStroke(10)); trajRenderer.setSeriesLinesVisible(1, true); trajRenderer.setSeriesShapesVisible(1, false); XYLineAndShapeRenderer velRenderer = new XYLineAndShapeRenderer(); velRenderer.setSeriesPaint(0, Color.MAGENTA); velRenderer.setSeriesLinesVisible(0, true); velRenderer.setSeriesShapesVisible(0, false); // renderer.setSeriesStroke(1, new BasicStroke(0.01f)); plot.setRenderer(0, posRenderer); plot.setRenderer(1, trajRenderer); plot.setRenderer(2, velRenderer); for (Setpoint s : trajectory) { Marker marker = new ValueMarker(s.time); marker.setPaint(Color.DARK_GRAY); marker.setLabel(Float.toString((float) s.position)); marker.setLabelAnchor(RectangleAnchor.TOP_LEFT); marker.setLabelTextAnchor(TextAnchor.TOP_RIGHT); plot.addDomainMarker(marker); } XYTextAnnotation p = new XYTextAnnotation("kP = " + gains.kP, plot.getDomainAxis().getUpperBound() * 0.125, plot.getRangeAxis().getUpperBound() * .75); p.setFont(new Font("Dialog", Font.PLAIN, 12)); plot.addAnnotation(p); XYTextAnnotation i = new XYTextAnnotation("kI = " + gains.kI, plot.getDomainAxis().getUpperBound() * 0.125, plot.getRangeAxis().getUpperBound() * .7); i.setFont(new Font("Dialog", Font.PLAIN, 12)); plot.addAnnotation(i); XYTextAnnotation d = new XYTextAnnotation("kD = " + gains.kD, plot.getDomainAxis().getUpperBound() * 0.125, plot.getRangeAxis().getUpperBound() * .65); d.setFont(new Font("Dialog", Font.PLAIN, 12)); plot.addAnnotation(d); // change the auto tick unit selection to integer units only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setAutoRange(true); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:gov.nih.nci.caintegrator.ui.graphing.chart.plot.KaplanMeierPlot.java
private void createChart(XYDataset dataset) { //Create the chart, dropping in the data set JFreeChart chart = ChartFactory.createXYLineChart("", "Days in Study", "Probability of Survival", dataset, PlotOrientation.VERTICAL, false, //legend true, //tooltips false//urls );//from w w w . ja va 2 s.c o m LegendTitle legend = chart.getLegend(); XYPlot plot = (XYPlot) chart.getPlot(); /******************************************************** * IMPORTANT: * Ideally I would create the actual Renderer settings for * the at the time I start to march through the * KaplanMeierPlotPointSeriesSets, adding them to the actual * Data Set that is going to be going into the Chart plotter. * But you have no idea how they are going to be sitting in * the Plot dataset so there is no guarantee that setting the * renderer based on a supposed index will actually work. In fact * it didn't work when I wrote this. * */ XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); for (int i = 0; i < finalDataCollection.getSeriesCount(); i++) { KaplanMeierPlotPointSeries kmSeries = (KaplanMeierPlotPointSeries) finalDataCollection.getSeries(i); if (kmSeries.getType() == SeriesType.CENSOR) { renderer.setSeriesLinesVisible(i, false); renderer.setSeriesShapesVisible(i, true); } else if (kmSeries.getType() == SeriesType.PROBABILITY) { renderer.setSeriesLinesVisible(i, true); renderer.setSeriesShapesVisible(i, false); } else { //don't show this set as it is not a known type renderer.setSeriesLinesVisible(i, false); renderer.setSeriesShapesVisible(i, false); } renderer.setSeriesPaint(i, getKMSetColor(kmSeries.getKey(), kmSeries.getType()), true); } renderer.setToolTipGenerator(new StandardXYToolTipGenerator()); renderer.setDefaultEntityRadius(6); plot.setRenderer(renderer); //change the auto tick unit selection to integer units only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits()); // OPTIONAL CUSTOMISATION COMPLETED. rangeAxis.setAutoRange(true); rangeAxis.setRange(0.0, 1.0); kmChart = chart; }
From source file:regression.gui.RegressionChart.java
/** * Creates a chart./*from w w w. j ava 2s. com*/ * * @param dataset the data for the chart. * * @return a chart. */ private JFreeChart createChart(final XYDataset dataset) { final JFreeChart chart = ChartFactory.createScatterPlot("Wykres funkcji regresji", // chart title "X", // x axis label "Y", // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesShape(0, ShapeUtilities.createRegularCross(3, 3)); renderer.setSeriesShape(2, ShapeUtilities.createRegularCross(3, 3)); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesShapesVisible(1, false); renderer.setSeriesLinesVisible(2, false); plot.setRenderer(renderer); final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return chart; }
From source file:org.agmip.ui.afsirs.frames.GraphOutput.java
public void addRain() { XYSeries rainSeries = new XYSeries("RAIN"); double[][] RAIN = utils.getRain(); for (int i = 0; i < 10/*RAIN.length*/; i++) { for (int j = 0; j < 10/*RAIN[0].length*/; j++) { rainSeries.add(i * RAIN[0].length + j, RAIN[i][j]); }/*from www. j a va 2 s. co m*/ } XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(rainSeries); JFreeChart chart = ChartFactory.createXYLineChart("Rain", "Days", "Inches", dataset/*, PlotOrientation.VERTICAL, true, true, false*/); chart.setBackgroundPaint(Color.white); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.GRAY); plot.setDomainGridlinePaint(Color.WHITE); plot.setRangeGridlinePaint(Color.white); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesShapesVisible(1, false); plot.setRenderer(renderer); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); ChartPanel panel = new ChartPanel(chart); jTabbedPane1.addTab("Rain", panel); }
From source file:org.agmip.ui.afsirs.frames.GraphOutput.java
public void addEvaporationAndTranspiration() { XYSeries etSeries = new XYSeries("ET"); double[][] ET = utils.getET(); for (int i = 0; i < 10/*ET.length*/; i++) { for (int j = 0; j < 10/*ET[0].length*/; j++) { etSeries.add(i * ET[0].length + j, ET[i][j]); }/*from w ww . ja v a 2 s .co m*/ } XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(etSeries); JFreeChart chart = ChartFactory.createXYLineChart("Evaporation Transpiration", "Days", "Inches", dataset/*, PlotOrientation.VERTICAL, true, true, false*/); chart.setBackgroundPaint(Color.white); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.GRAY); plot.setDomainGridlinePaint(Color.WHITE); plot.setRangeGridlinePaint(Color.white); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesShapesVisible(1, false); plot.setRenderer(renderer); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); ChartPanel panel = new ChartPanel(chart); jTabbedPane1.addTab("Evaporation Transpiration", panel); }
From source file:org.agmip.ui.afsirs.frames.GraphOutput.java
public void addWeather() { int nyr = utils.getNYR(); XYSeries etSeries = new XYSeries("ET"); double[][] ET = utils.getET(); for (int i = 0; i < 10/*ET.length*/; i++) { for (int j = 0; j < 10/*ET[0].length*/; j++) { etSeries.add(i * ET[0].length + j, ET[i][j]); }// w ww .ja va 2 s . c o m } XYSeries rainSeries = new XYSeries("RAIN"); double[][] RAIN = utils.getRain(); for (int i = 0; i < 10/*RAIN.length*/; i++) { for (int j = 0; j < 10/*RAIN[0].length*/; j++) { rainSeries.add(i * RAIN[0].length + j, RAIN[i][j]); } } XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(etSeries); dataset.addSeries(rainSeries); JFreeChart chart = ChartFactory.createXYLineChart("Weather Data", "Days", "Inches", dataset/*, PlotOrientation.VERTICAL, true, true, false*/); chart.setBackgroundPaint(Color.white); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.GRAY); plot.setDomainGridlinePaint(Color.WHITE); plot.setRangeGridlinePaint(Color.white); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesShapesVisible(1, false); plot.setRenderer(renderer); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); ChartPanel panel = new ChartPanel(chart); jTabbedPane1.addTab("Weather", panel); }
From source file:org.hsh.bfr.db.gui.dbtable.editoren.MyChartDialog.java
/** * Creates a chart./*from w w w. j a v a2 s . c o m*/ * * @param dataset the data for the chart. * * @return a chart. */ private JFreeChart createChart(final XYDataset dataset, String xAxis, String yAxis) { // create the chart... final JFreeChart chart = ChartFactory.createXYLineChart("", // chart title xAxis, // x axis label yAxis, // y axis label dataset, // data PlotOrientation.VERTICAL, false, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); // final StandardLegend legend = (StandardLegend) chart.getLegend(); // legend.setDisplaySeriesShapes(true); // get a reference to the plot for further customisation... final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); //plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, true); renderer.setSeriesShapesVisible(0, false); plot.setRenderer(renderer); // change the auto tick unit selection to integer units only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:treegross.standsimulation.TgGrafik.java
public JFreeChart createChart(Stand st) { // create the dataset... XYSeriesCollection dataset = new XYSeriesCollection(); for (int i = 0; i < st.nspecies; i++) { XYSeries series = new XYSeries(st.sp[i].spDef.shortName); // DefaultCategoryDataset dataset = new DefaultCategoryDataset(); for (int k = 0; k < st.ntrees; k++) { if ((st.tr[k].d > 0) && st.tr[k].out < 0 && st.tr[k].code == st.sp[i].code) series.add(st.tr[k].d, st.tr[k].h); }/* www . j a v a 2s . c om*/ dataset.addSeries(series); } // JFreeChart chart = ChartFactory.createScatterPlot(messages.getString("heightDiameter"), messages.getString("dbh"), messages.getString("height"), dataset, org.jfree.chart.plot.PlotOrientation.VERTICAL, true, false, false); XYPlot plot = chart.getXYPlot(); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); // // XYPlot plot = chart.getXYPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); for (int i = 0; i < st.nspecies; i++) { renderer.setSeriesLinesVisible(i, false); renderer.setSeriesPaint(i, new Color(st.sp[i].spDef.colorRed, st.sp[i].spDef.colorGreen, st.sp[i].spDef.colorBlue)); } plot.setRenderer(renderer); return chart; }