List of usage examples for org.jfree.chart.plot CombinedRangeXYPlot add
public void add(XYPlot subplot, int weight)
From source file:org.jfree.chart.demo.CombinedTimeSeriesDemo1.java
public static JPanel createDemoPanel() { TimeSeries timeseries = new TimeSeries("Annual"); timeseries.add(new Year(1998), 80D); timeseries.add(new Year(1999), 85D); timeseries.add(new Year(2000), 87.599999999999994D); TimeSeriesCollection dataset1 = new TimeSeriesCollection(timeseries); TimeSeries timeseries1 = new TimeSeries("Monthly A"); timeseries1.add(new Month(7, 2000), 85.799999999999997D); timeseries1.add(new Month(8, 2000), 85.799999999999997D); timeseries1.add(new Month(9, 2000), 85.799999999999997D); timeseries1.add(new Month(10, 2000), 86.5D); timeseries1.add(new Month(11, 2000), 86.5D); timeseries1.add(new Month(12, 2000), 86.5D); timeseries1.add(new Month(1, 2001), 87.700000000000003D); timeseries1.add(new Month(2, 2001), 87.700000000000003D); timeseries1.add(new Month(3, 2001), 87.700000000000003D); timeseries1.add(new Month(4, 2001), 88.5D); timeseries1.add(new Month(5, 2001), 88.5D); timeseries1.add(new Month(6, 2001), 88.5D); timeseries1.add(new Month(7, 2001), 90D); timeseries1.add(new Month(8, 2001), 90D); timeseries1.add(new Month(9, 2001), 90D); timeseries1.add(new Month(10, 2001), 90D); timeseries1.add(new Month(11, 2001), 90D); timeseries1.add(new Month(12, 2001), 90D); timeseries1.add(new Month(1, 2002), 90D); timeseries1.add(new Month(2, 2002), 90D); timeseries1.add(new Month(3, 2002), 90D); timeseries1.add(new Month(4, 2002), 90D); timeseries1.add(new Month(5, 2002), 90D); timeseries1.add(new Month(6, 2002), 90D); TimeSeries timeseries2 = new TimeSeries("Monthly B"); timeseries2.add(new Month(7, 2000), 83.799999999999997D); timeseries2.add(new Month(8, 2000), 83.799999999999997D); timeseries2.add(new Month(9, 2000), 83.799999999999997D); timeseries2.add(new Month(10, 2000), 84.5D); timeseries2.add(new Month(11, 2000), 84.5D); timeseries2.add(new Month(12, 2000), 84.5D); timeseries2.add(new Month(1, 2001), 85.700000000000003D); timeseries2.add(new Month(2, 2001), 85.700000000000003D); timeseries2.add(new Month(3, 2001), 85.700000000000003D); timeseries2.add(new Month(4, 2001), 86.5D); timeseries2.add(new Month(5, 2001), 86.5D); timeseries2.add(new Month(6, 2001), 86.5D); timeseries2.add(new Month(7, 2001), 88D); timeseries2.add(new Month(8, 2001), 88D); timeseries2.add(new Month(9, 2001), 88D); timeseries2.add(new Month(10, 2001), 88D); timeseries2.add(new Month(11, 2001), 88D); timeseries2.add(new Month(12, 2001), 88D); timeseries2.add(new Month(1, 2002), 88D); timeseries2.add(new Month(2, 2002), 88D); timeseries2.add(new Month(3, 2002), 88D); timeseries2.add(new Month(4, 2002), 88D); timeseries2.add(new Month(5, 2002), 88D); timeseries2.add(new Month(6, 2002), 88D); TimeSeriesCollection dataset21 = new TimeSeriesCollection(); dataset21.addSeries(timeseries1);/*from www .j a v a 2s. com*/ dataset21.addSeries(timeseries2); TimeSeries timeseries3 = new TimeSeries("XXX"); timeseries3.add(new Month(7, 2000), 81.5D); timeseries3.add(new Month(8, 2000), 86D); timeseries3.add(new Month(9, 2000), 82D); timeseries3.add(new Month(10, 2000), 89.5D); timeseries3.add(new Month(11, 2000), 88D); timeseries3.add(new Month(12, 2000), 88D); timeseries3.add(new Month(1, 2001), 90D); timeseries3.add(new Month(2, 2001), 89.5D); timeseries3.add(new Month(3, 2001), 90.200000000000003D); timeseries3.add(new Month(4, 2001), 90.599999999999994D); timeseries3.add(new Month(5, 2001), 87.5D); timeseries3.add(new Month(6, 2001), 91D); timeseries3.add(new Month(7, 2001), 89.700000000000003D); timeseries3.add(new Month(8, 2001), 87D); timeseries3.add(new Month(9, 2001), 91.200000000000003D); timeseries3.add(new Month(10, 2001), 84D); timeseries3.add(new Month(11, 2001), 90D); timeseries3.add(new Month(12, 2001), 92D); TimeSeriesCollection dataset22 = new TimeSeriesCollection(timeseries3); // XYBarRenderer renderer1 = new XYBarRenderer(0.20000000000000001D); renderer1.setBaseToolTipGenerator(new StandardXYToolTipGenerator("{0} ({1}, {2})", new SimpleDateFormat("yyyy"), new DecimalFormat("0.00"))); XYPlot plot1 = new XYPlot(dataset1, new DateAxis("Date"), null, renderer1); // XYAreaRenderer renderer21 = new XYAreaRenderer(); XYPlot plot2 = new XYPlot(dataset21, new DateAxis("Date"), null, renderer21); StandardXYItemRenderer renderer22 = new StandardXYItemRenderer(3); renderer22.setBaseShapesFilled(true); plot2.setDataset(1, dataset22); plot2.setRenderer(1, renderer22); plot2.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); // NumberAxis valueAxis = new NumberAxis("Value"); valueAxis.setAutoRangeIncludesZero(false); CombinedRangeXYPlot combinedPlot = new CombinedRangeXYPlot(valueAxis); combinedPlot.add(plot1, 1); combinedPlot.add(plot2, 4); //chart JFreeChart jfreechart = new JFreeChart("Sample Combined Plot", JFreeChart.DEFAULT_TITLE_FONT, combinedPlot, true); ChartPanel chartpanel = new ChartPanel(jfreechart); chartpanel.setPreferredSize(new Dimension(500, 270)); chartpanel.addChartMouseListener(new ChartMouseListener() { public void chartMouseClicked(ChartMouseEvent chartmouseevent) { System.out.println(chartmouseevent.getEntity()); } public void chartMouseMoved(ChartMouseEvent chartmouseevent) { System.out.println(chartmouseevent.getEntity()); } }); return chartpanel; }
From source file:org.jfree.chart.demo.SymbolicXYPlotDemo.java
/** * Displays an horizontally combined XYPlot with X and Y symbolic data. * // w ww.j a v a 2 s . c o m * @param frameTitle * the frame title. * @param data1 * the dataset 1. * @param data2 * the dataset 2. */ private static void displayXYSymbolicCombinedHorizontally(final String frameTitle, final XYDataset data1, final XYDataset data2) { final String title = "Pollutant Horizontally Combined"; final String x1AxisLabel = "Contamination"; final String x2AxisLabel = "Type"; final String yAxisLabel = "Pollutant"; // combine the y symbolic values of the two data sets final String[] combinedYSymbolicValues = SampleXYSymbolicDataset .combineYSymbolicDataset((YisSymbolic) data1, (YisSymbolic) data2); // make master dataset... final CombinedDataset data = new CombinedDataset(); data.add(data1); data.add(data2); // decompose data... final XYDataset series0 = new SubSeriesDataset(data, 0); final XYDataset series1 = new SubSeriesDataset(data, 1); JFreeChart chart = null; // common horizontal and vertical axes final SymbolicAxis hsymbolicAxis0 = new SymbolicAxis(x1AxisLabel, ((XisSymbolic) data1).getXSymbolicValues()); final SymbolicAxis hsymbolicAxis1 = new SymbolicAxis(x2AxisLabel, ((XisSymbolic) data2).getXSymbolicValues()); final SymbolicAxis symbolicAxis = new SymbolicAxis(yAxisLabel, combinedYSymbolicValues); // create main plot... final CombinedRangeXYPlot mainPlot = new CombinedRangeXYPlot(symbolicAxis); // add subplots... final XYItemRenderer renderer = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, null); final XYPlot subplot0 = new XYPlot(series0, hsymbolicAxis0, null, renderer); final XYPlot subplot1 = new XYPlot(series1, hsymbolicAxis1, null, renderer); mainPlot.add(subplot0, 1); mainPlot.add(subplot1, 1); // make the top level JFreeChart object chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, mainPlot, true); chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.blue)); // and present it in a frame... final JFrame frame = new ChartFrame(frameTitle, chart); frame.pack(); RefineryUtilities.positionFrameRandomly(frame); frame.show(); }
From source file:org.jfree.chart.demo.CombinedXYPlotDemo2.java
/** * Creates a combined XYPlot chart.//from w w w . j a va 2 s . c o m * * @return the combined chart. */ private JFreeChart createCombinedChart() { // create subplot 1... final IntervalXYDataset data1 = createDataset1(); final XYItemRenderer renderer1 = new XYBarRenderer(0.20); renderer1.setToolTipGenerator( new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0,000.0"))); final XYPlot subplot1 = new XYPlot(data1, new DateAxis("Date"), null, renderer1); // create subplot 2... final XYDataset data2 = createDataset2(); final XYItemRenderer renderer2 = new StandardXYItemRenderer(); renderer2.setToolTipGenerator( new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0,000.0"))); final XYPlot subplot2 = new XYPlot(data2, new DateAxis("Date"), null, renderer2); // create a parent plot... final CombinedRangeXYPlot plot = new CombinedRangeXYPlot(new NumberAxis("Value")); // add the subplots... plot.add(subplot1, 1); plot.add(subplot2, 1); // return a new chart containing the overlaid plot... return new JFreeChart("Combined (Range) XY Plot", JFreeChart.DEFAULT_TITLE_FONT, plot, true); }
From source file:org.optaplanner.examples.cheaptime.swingui.CheapTimePanel.java
private JFreeChart createChart(CheapTimeSolution solution) { TangoColorFactory tangoColorFactory = new TangoColorFactory(); NumberAxis rangeAxis = new NumberAxis("Period"); rangeAxis.setRange(-0.5, solution.getGlobalPeriodRangeTo() + 0.5); XYPlot taskAssignmentPlot = createTaskAssignmentPlot(tangoColorFactory, solution); XYPlot periodCostPlot = createPeriodCostPlot(tangoColorFactory, solution); XYPlot capacityPlot = createAvailableCapacityPlot(tangoColorFactory, solution); CombinedRangeXYPlot combinedPlot = new CombinedRangeXYPlot(rangeAxis); combinedPlot.add(taskAssignmentPlot, 5); combinedPlot.add(periodCostPlot, 1); combinedPlot.add(capacityPlot, 1);/*www. j av a 2 s.c om*/ combinedPlot.setOrientation(PlotOrientation.HORIZONTAL); return new JFreeChart("Cheap Power Time Scheduling", JFreeChart.DEFAULT_TITLE_FONT, combinedPlot, true); }
From source file:org.jfree.chart.demo.CombinedXYPlotDemo3.java
/** * Creates a combined XYPlot chart./* ww w.j a v a 2 s. c om*/ * * @return the combined chart. */ private JFreeChart createCombinedChart() { // create a default chart based on some sample data... final TimeSeriesCollection dataset0 = new TimeSeriesCollection(); final TimeSeries eur = DemoDatasetFactory.createEURTimeSeries(); dataset0.addSeries(eur); final TimeSeriesCollection dataset1 = new TimeSeriesCollection(); final TimeSeries mav = MovingAverage.createMovingAverage(eur, "EUR/GBP (30 Day MA)", 30, 30); dataset1.addSeries(eur); dataset1.addSeries(mav); final TimeSeriesCollection dataset2 = new TimeSeriesCollection(); dataset2.addSeries(eur); JFreeChart chart = null; // make a common vertical axis for all the sub-plots final NumberAxis valueAxis = new NumberAxis("Value"); valueAxis.setAutoRangeIncludesZero(false); // override default // make a horizontally combined plot final CombinedRangeXYPlot parent = new CombinedRangeXYPlot(valueAxis); // add subplot 1... final XYPlot subplot1 = new XYPlot(dataset0, new DateAxis("Date 1"), null, new StandardXYItemRenderer()); parent.add(subplot1, 1); // add subplot 2... final XYPlot subplot2 = new XYPlot(dataset1, new DateAxis("Date 2"), null, new StandardXYItemRenderer()); parent.add(subplot2, 1); // add subplot 3... final XYPlot subplot3 = new XYPlot(dataset2, new DateAxis("Date 3"), null, new XYBarRenderer(0.20)); parent.add(subplot3, 1); // now make the top level JFreeChart chart = new JFreeChart("Demo Chart", JFreeChart.DEFAULT_TITLE_FONT, parent, true); // then customise it a little... final TextTitle subtitle = new TextTitle("This is a subtitle", new Font("SansSerif", Font.BOLD, 12)); chart.addSubtitle(subtitle); chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.blue)); return chart; }
From source file:org.jfree.chart.demo.CombinedXYPlotDemo5.java
/** * Creates a combined XYPlot chart./*ww w. j ava 2 s . c om*/ * * @return the combined chart. */ private JFreeChart createCombinedChart() { // create a default chart based on some sample data... final TimeSeriesCollection dataset0 = new TimeSeriesCollection(); final TimeSeries eur = DemoDatasetFactory.createEURTimeSeries(); dataset0.addSeries(eur); final TimeSeriesCollection dataset1 = new TimeSeriesCollection(); final TimeSeries mav = MovingAverage.createMovingAverage(eur, "EUR/GBP (30 Day MA)", 30, 30); dataset1.addSeries(eur); dataset1.addSeries(mav); final TimeSeriesCollection dataset2 = new TimeSeriesCollection(); dataset2.addSeries(eur); JFreeChart chart = null; // make a common vertical axis for all the sub-plots final NumberAxis valueAxis = new NumberAxis("Value"); valueAxis.setAutoRangeIncludesZero(false); // override default // make a horizontally combined plot final CombinedRangeXYPlot parent = new CombinedRangeXYPlot(valueAxis); // add subplot 1... final XYPlot subplot1 = new XYPlot(dataset0, new DateAxis("Date 1"), null, new StandardXYItemRenderer()); subplot1.setDomainCrosshairVisible(true); subplot1.setRangeCrosshairVisible(true); parent.add(subplot1, 1); // add subplot 2... final XYPlot subplot2 = new XYPlot(dataset1, new DateAxis("Date 2"), null, new StandardXYItemRenderer()); subplot2.setDomainCrosshairVisible(true); subplot2.setRangeCrosshairVisible(true); parent.add(subplot2, 1); // add subplot 3... final XYPlot subplot3 = new XYPlot(dataset2, new DateAxis("Date 3"), null, new XYBarRenderer(0.20)); subplot3.setDomainCrosshairVisible(true); subplot3.setRangeCrosshairVisible(true); parent.add(subplot3, 1); // now make the top level JFreeChart chart = new JFreeChart("Demo Chart", JFreeChart.DEFAULT_TITLE_FONT, parent, true); // then customise it a little... final TextTitle subtitle = new TextTitle("This is a subtitle", new Font("SansSerif", Font.BOLD, 12)); chart.addSubtitle(subtitle); chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.blue)); return chart; }
From source file:org.jfree.chart.demo.SymbolicYPlotDemo.java
/** * Create and display a multi XY plot with horizontal layout. * /*w w w .j av a 2 s. com*/ * @param frameTitle * the frame title. * @param data1 * dataset1. * @param data2 * dataset2. */ private static void displayYSymbolicCombinedHorizontally(final String frameTitle, final SampleYSymbolicDataset data1, final SampleYSymbolicDataset data2) { final String title = "Animals Horizontally Combined"; final String xAxisLabel = "Miles"; final String yAxisLabel = null; // combine the y symbolic values of the two data sets final String[] combinedYSymbolicValues = SampleYSymbolicDataset.combineYSymbolicDataset(data1, data2); // make master dataset... final CombinedDataset data = new CombinedDataset(); data.add(data1); data.add(data2); // decompose data... final XYDataset series0 = new SubSeriesDataset(data, 0); final XYDataset series1 = new SubSeriesDataset(data, 1); final XYDataset series2 = new SubSeriesDataset(data, 2); final XYDataset series3 = new SubSeriesDataset(data, 3); final XYDataset series4 = new SubSeriesDataset(data, 4); final XYDataset series5 = new SubSeriesDataset(data, 5); final XYDataset series6 = new SubSeriesDataset(data, 6); final XYDataset series7 = new SubSeriesDataset(data, 7); // create axes... final ValueAxis valueAxis0 = new NumberAxis(xAxisLabel); final ValueAxis valueAxis1 = new NumberAxis(xAxisLabel); final ValueAxis valueAxis2 = new NumberAxis(xAxisLabel); final ValueAxis valueAxis3 = new NumberAxis(xAxisLabel); final ValueAxis valueAxis4 = new NumberAxis(xAxisLabel); final ValueAxis valueAxis5 = new NumberAxis(xAxisLabel); final ValueAxis valueAxis6 = new NumberAxis(xAxisLabel); final ValueAxis valueAxis7 = new NumberAxis(xAxisLabel); final SymbolicAxis symbolicAxis = new SymbolicAxis(yAxisLabel, combinedYSymbolicValues); // make a combined plot final CombinedRangeXYPlot mainPlot = new CombinedRangeXYPlot(symbolicAxis); // add the sub-plots final XYItemRenderer renderer0 = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, null); final XYPlot subplot0 = new XYPlot(series0, valueAxis0, null, renderer0); final XYItemRenderer renderer1 = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, null); final XYPlot subplot1 = new XYPlot(series1, valueAxis1, null, renderer1); final XYItemRenderer renderer2 = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, null); final XYPlot subplot2 = new XYPlot(series2, valueAxis2, null, renderer2); final XYItemRenderer renderer3 = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, null); final XYPlot subplot3 = new XYPlot(series3, valueAxis3, null, renderer3); final XYItemRenderer renderer4 = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, null); final XYPlot subplot4 = new XYPlot(series4, valueAxis4, null, renderer4); final XYItemRenderer renderer5 = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, null); final XYPlot subplot5 = new XYPlot(series5, valueAxis5, null, renderer5); final XYItemRenderer renderer6 = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, null); final XYPlot subplot6 = new XYPlot(series6, valueAxis6, null, renderer6); final XYItemRenderer renderer7 = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, null); final XYPlot subplot7 = new XYPlot(series7, valueAxis7, null, renderer7); mainPlot.add(subplot0, 1); mainPlot.add(subplot1, 1); mainPlot.add(subplot2, 1); mainPlot.add(subplot3, 1); mainPlot.add(subplot4, 1); mainPlot.add(subplot5, 1); mainPlot.add(subplot6, 1); mainPlot.add(subplot7, 1); // make the top level JFreeChart object final JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, mainPlot, true); // then customise it a little... chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.blue)); // and present it in a frame... final JFrame ySymbolicFrame = new ChartFrame(frameTitle, chart); ySymbolicFrame.pack(); RefineryUtilities.positionFrameRandomly(ySymbolicFrame); ySymbolicFrame.show(); }
From source file:org.gwaspi.reports.PlinkReportLoaderCombined.java
private static void appendToCombinedRangePlot(CombinedRangeXYPlot combinedPlot, String chromosome, XYSeriesCollection tempChrData, boolean showlables) { XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(false, true); renderer.setSeriesPaint(0, Color.blue); renderer.setSeriesPaint(1, Color.red); renderer.setSeriesVisibleInLegend(0, showlables); renderer.setSeriesVisibleInLegend(1, showlables); //renderer.setBaseShape(new Ellipse2D.Float(0, 0, 2,2), false); if (combinedPlot.getSubplots().isEmpty()) { LogAxis rangeAxis = new LogAxis("P value"); rangeAxis.setBase(10);//from ww w . j a va2 s .com rangeAxis.setInverted(true); rangeAxis.setNumberFormatOverride(GenericReportGenerator.FORMAT_P_VALUE); rangeAxis.setTickMarkOutsideLength(2.0f); rangeAxis.setMinorTickCount(2); rangeAxis.setMinorTickMarksVisible(true); rangeAxis.setAxisLineVisible(true); rangeAxis.setAutoRangeMinimumSize(0.0000005); rangeAxis.setLowerBound(1d); //rangeAxis.setAutoRangeIncludesZero(false); combinedPlot.setRangeAxis(0, rangeAxis); } JFreeChart subchart = ChartFactory.createScatterPlot("", "Chr " + chromosome, "", tempChrData, PlotOrientation.VERTICAL, true, false, false); XYPlot subplot = (XYPlot) subchart.getPlot(); subplot.setRenderer(renderer); subplot.setBackgroundPaint(null); final Marker thresholdLine = new ValueMarker(0.0000005); thresholdLine.setPaint(Color.red); if (showlables) { thresholdLine.setLabel("P = 510??"); } thresholdLine.setLabelAnchor(RectangleAnchor.TOP_RIGHT); thresholdLine.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT); subplot.addRangeMarker(thresholdLine); NumberAxis chrAxis = (NumberAxis) subplot.getDomainAxis(); chrAxis.setAxisLineVisible(false); chrAxis.setTickLabelsVisible(false); chrAxis.setTickMarksVisible(false); chrAxis.setAutoRangeIncludesZero(false); //combinedPlot.setGap(0); combinedPlot.add(subplot, 1); }
From source file:org.jax.haplotype.analysis.visualization.GenomicGraphFactory.java
/** * Creates a plot which contains multiple chromosome histograms * @param chromosomeHistograms// ww w .ja v a2s . co m * the chromosome histograms * @param xAxisLabel * the X axis label * @param yAxisLabel * the Y axis label * @return * the object for the multiple chromosome plots */ public JFreeChart createMultiChromosomeHistogram( final List<? extends ChromosomeHistogramValues> chromosomeHistograms, final String xAxisLabel, final String yAxisLabel) { // create the y-axis that is shared by all of the chromosomes NumberAxis yAxis = new NumberAxis(); if (yAxisLabel != null) { yAxis.setLabel(yAxisLabel); } // the combined plot makes all of the chromosomes to share the same // y-axis but to have thier own x-axis CombinedRangeXYPlot combinedChromosomePlot = new CombinedRangeXYPlot(yAxis); combinedChromosomePlot.setGap(4.0); // iterate through the chromosomes adding a new plot for each one for (ChromosomeHistogramValues currChromHist : chromosomeHistograms) { // use a weight to ensure that the amount of space that the // subgraph gets on the x-axis is proportional to the chromosome's // extent final int currWeight = (int) (currChromHist.getExtentInBasePairs() / 1000 + 1); final NumberAxis currXAxis = new NumberAxis(); currXAxis.setAutoRangeIncludesZero(false); currXAxis.setTickLabelsVisible(false); currXAxis.setTickMarksVisible(false); currXAxis.setLabel(Integer.toString(currChromHist.getChromosomeNumber())); final XYPlot currPlot = this.createSnpIntervalHistogramPlot(currChromHist.getIntervals(), currChromHist.getVisualInterval(), currXAxis, null); combinedChromosomePlot.add(currPlot, currWeight); } JFreeChart multiChromosomeChart = new JFreeChart(combinedChromosomePlot); multiChromosomeChart.removeLegend(); return multiChromosomeChart; }
From source file:org.gwaspi.reports.PlinkReportLoader.java
private static void appendToCombinedRangePlot(CombinedRangeXYPlot combinedPlot, String chromosome, XYSeriesCollection seriesCol) {/*from w w w . j a v a2s . co m*/ XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(false, true); renderer.setSeriesPaint(0, Color.blue); JFreeChart subchart = ChartFactory.createScatterPlot("", "Chr " + chromosome, "", seriesCol, PlotOrientation.VERTICAL, true, false, false); XYPlot subplot = (XYPlot) subchart.getPlot(); subplot.setRenderer(renderer); subplot.setBackgroundPaint(null); subplot.setDomainGridlineStroke(new BasicStroke(0.0f)); subplot.setDomainMinorGridlineStroke(new BasicStroke(0.0f)); subplot.setDomainGridlinePaint(Color.blue); subplot.setRangeGridlineStroke(new BasicStroke(0.0f)); subplot.setRangeMinorGridlineStroke(new BasicStroke(0.0f)); subplot.setRangeGridlinePaint(Color.blue); NumberAxis chrAxis = (NumberAxis) subplot.getDomainAxis(); chrAxis.setAxisLineVisible(true); chrAxis.setTickLabelsVisible(true); chrAxis.setTickMarksVisible(true); chrAxis.setTickUnit(new NumberTickUnit(10000)); chrAxis.setAutoRangeIncludesZero(false); NumberAxis log10Axis = (NumberAxis) subplot.getRangeAxis(); log10Axis.setTickMarkInsideLength(2.0f); log10Axis.setTickMarkOutsideLength(2.0f); log10Axis.setMinorTickCount(2); log10Axis.setMinorTickMarksVisible(true); log10Axis.setAxisLineVisible(true); log10Axis.setAutoRangeIncludesZero(false); XYItemRenderer lblRenderer = subplot.getRenderer(); MySeriesItemLabelGenerator lblGenerator = new MySeriesItemLabelGenerator(4.0d, chromosome); lblRenderer.setSeriesItemLabelGenerator(0, lblGenerator); lblRenderer.setSeriesItemLabelGenerator(1, lblGenerator); lblRenderer.setSeriesItemLabelFont(0, new Font("Serif", Font.PLAIN, 12)); lblRenderer.setSeriesItemLabelFont(1, new Font("Serif", Font.PLAIN, 12)); lblRenderer.setSeriesPositiveItemLabelPosition(0, new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.BOTTOM_LEFT, TextAnchor.TOP_LEFT, -Math.PI / 4.0)); lblRenderer.setSeriesPositiveItemLabelPosition(1, new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.BOTTOM_LEFT, TextAnchor.TOP_LEFT, -Math.PI / 4.0)); lblRenderer.setSeriesItemLabelsVisible(0, true); lblRenderer.setSeriesItemLabelsVisible(1, true); combinedPlot.add(subplot, 1); }