List of usage examples for org.jfree.chart.plot XYPlot setDomainGridlineStroke
public void setDomainGridlineStroke(Stroke stroke)
From source file:org.ala.spatial.web.services.GDMWSController.java
public static void generateCharts123(String outputdir) { try {//www . ja v a2 s . c o m IniReader ir = new IniReader(outputdir + "/gdm_params.txt"); double intercept = ir.getDoubleValue("GDMODEL", "Intercept"); // 1. read the ObservedVsPredicted.csv file System.out.println("Loading csv data"); CSVReader csv = new CSVReader(new FileReader(outputdir + "ObservedVsPredicted.csv")); List<String[]> rawdata = csv.readAll(); double[][] dataCht1 = new double[2][rawdata.size() - 1]; double[][] dataCht2 = new double[2][rawdata.size() - 1]; // for Chart 1: obs count int[] obscount = new int[11]; for (int i = 0; i < obscount.length; i++) { obscount[i] = 0; } System.out.println("populating data"); for (int i = 1; i < rawdata.size(); i++) { String[] row = rawdata.get(i); double obs = Double.parseDouble(row[4]); dataCht1[0][i - 1] = Double.parseDouble(row[6]); dataCht1[1][i - 1] = obs; dataCht2[0][i - 1] = Double.parseDouble(row[5]) - intercept; dataCht2[1][i - 1] = obs; int obc = (int) Math.round(obs * 10); obscount[obc]++; } DefaultXYDataset dataset1 = new DefaultXYDataset(); dataset1.addSeries("", dataCht1); DefaultXYDataset dataset2 = new DefaultXYDataset(); dataset2.addSeries("", dataCht2); DefaultCategoryDataset dataset3 = new DefaultCategoryDataset(); for (int i = 0; i < obscount.length; i++) { String col = "0." + i + "-0." + (i + 1); if (i == 10) { col = "0.9-1.0"; } dataset3.addValue(obscount[i] + 100, "col", col); } generateChartByType("Response Histogram", "Observed Dissimilarity Class", "Number of Site Pairs", dataset3, outputdir, "bar", "resphist"); XYDotRenderer renderer = new XYDotRenderer(); //Shape cross = ShapeUtilities.createDiagonalCross(3, 1); //renderer.setSeriesShape(0, cross); renderer.setDotWidth(3); renderer.setDotHeight(3); renderer.setSeriesPaint(0, Color.BLACK); JFreeChart jChart1 = ChartFactory.createScatterPlot( "Observed versus predicted compositional dissimilarity", "Predicted Compositional Dissimilarity", "Observed Compositional Dissimilarity", dataset1, PlotOrientation.VERTICAL, false, false, false); jChart1.getTitle().setFont(new Font(Font.MONOSPACED, Font.PLAIN, 14)); XYPlot plot = (XYPlot) jChart1.getPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setDomainZeroBaselineVisible(true); plot.setRangeZeroBaselineVisible(true); plot.setDomainGridlinesVisible(true); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); plot.setDomainGridlineStroke(new BasicStroke(0.5F, 0, 1)); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); plot.setRangeGridlineStroke(new BasicStroke(0.5F, 0, 1)); plot.setRenderer(0, renderer); NumberAxis domain = (NumberAxis) plot.getDomainAxis(); domain.setAutoRangeIncludesZero(false); domain.setAxisLineVisible(false); domain.setLabelFont(new Font(Font.MONOSPACED, Font.PLAIN, 12)); NumberAxis range = (NumberAxis) plot.getRangeAxis(); range.setAutoRangeIncludesZero(false); range.setAxisLineVisible(false); range.setLabelFont(new Font(Font.MONOSPACED, Font.PLAIN, 12)); double dMinPred = domain.getRange().getLowerBound(); double dMaxPred = domain.getRange().getUpperBound(); double dMinObs = range.getRange().getLowerBound(); double dMaxObs = range.getRange().getUpperBound(); System.out.println("1..pred.min.max: " + dMinPred + ", " + dMaxPred); int regressionLineSegs = 10; double dInc = (dMaxPred - dMinPred) / regressionLineSegs; double[][] dataReg1 = new double[2][regressionLineSegs + 1]; DefaultXYDataset dsReg1 = new DefaultXYDataset(); int i = 0; for (double d = dMinPred; d <= dMaxPred; d += dInc, i++) { dataReg1[0][i] = d; dataReg1[1][i] = d; } dsReg1.addSeries("", dataReg1); XYSplineRenderer regressionRenderer = new XYSplineRenderer(); regressionRenderer.setBaseSeriesVisibleInLegend(true); regressionRenderer.setSeriesPaint(0, Color.RED); regressionRenderer.setSeriesStroke(0, new BasicStroke(1.5f)); regressionRenderer.setBaseShapesVisible(false); plot.setDataset(1, dsReg1); plot.setRenderer(1, regressionRenderer); System.out.println("Writing image...."); ChartUtilities.saveChartAsPNG(new File(outputdir + "plots/obspredissim.png"), jChart1, 600, 400); // For chart 3 JFreeChart jChart2 = ChartFactory.createScatterPlot( "Observed compositional dissimilarity vs predicted ecological distance", "Predicted ecological distance", "Observed Compositional Dissimilarity", dataset2, PlotOrientation.VERTICAL, false, false, false); jChart2.getTitle().setFont(new Font(Font.MONOSPACED, Font.PLAIN, 14)); plot = (XYPlot) jChart2.getPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setDomainZeroBaselineVisible(true); plot.setRangeZeroBaselineVisible(true); plot.setDomainGridlinesVisible(true); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); plot.setDomainGridlineStroke(new BasicStroke(0.5F, 0, 1)); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); plot.setRangeGridlineStroke(new BasicStroke(0.5F, 0, 1)); plot.setRenderer(0, renderer); domain = (NumberAxis) plot.getDomainAxis(); domain.setAutoRangeIncludesZero(false); domain.setAxisLineVisible(false); domain.setLabelFont(new Font(Font.MONOSPACED, Font.PLAIN, 12)); range = (NumberAxis) plot.getRangeAxis(); range.setAutoRangeIncludesZero(false); range.setAxisLineVisible(false); range.setLabelFont(new Font(Font.MONOSPACED, Font.PLAIN, 12)); dMinPred = domain.getRange().getLowerBound(); dMaxPred = domain.getRange().getUpperBound(); dMinObs = range.getRange().getLowerBound(); dMaxObs = range.getRange().getUpperBound(); System.out.println("2.pred.min.max: " + dMinPred + ", " + dMaxPred); regressionLineSegs = 10; dInc = (dMaxPred - dMinPred) / regressionLineSegs; dataReg1 = new double[2][regressionLineSegs + 1]; dsReg1 = new DefaultXYDataset(); i = 0; for (double d = dMinPred; d <= dMaxPred; d += dInc, i++) { dataReg1[0][i] = d; dataReg1[1][i] = (1.0 - Math.exp(-d)); } dsReg1.addSeries("", dataReg1); regressionRenderer.setBaseSeriesVisibleInLegend(true); regressionRenderer.setSeriesPaint(0, Color.RED); regressionRenderer.setSeriesStroke(0, new BasicStroke(1.5f)); regressionRenderer.setBaseShapesVisible(false); plot.setDataset(1, dsReg1); plot.setRenderer(1, regressionRenderer); System.out.println("Writing image...."); ChartUtilities.saveChartAsPNG(new File(outputdir + "plots/dissimdist.png"), jChart2, 600, 400); } catch (Exception e) { System.out.println("Unable to generate charts 2 and 3:"); e.printStackTrace(System.out); } }
From source file:wattsup.jsdk.ui.ChartPanelSupport.java
/** * Clean the values of the chart./* w ww .j a v a 2s . c om*/ * * @see #createChart() */ public void cleanChart() { this.chart_.removeLegend(); this.chartPanel_.setBorder(null); cleanLabels(); DateAxis localDateAxis = (DateAxis) ((XYPlot) this.chart_.getPlot()).getDomainAxis(); localDateAxis.setTickLabelsVisible(false); localDateAxis.setTickMarksVisible(false); localDateAxis.setAxisLineVisible(false); ValueAxis localValueAxis = ((XYPlot) this.chart_.getPlot()).getRangeAxis(); localValueAxis.setTickLabelsVisible(false); localValueAxis.setTickMarksVisible(false); localValueAxis.setAxisLineVisible(false); XYPlot localXYPlot = (XYPlot) this.chart_.getPlot(); localXYPlot.setDomainGridlineStroke(this.defaultLineStroke_); localXYPlot.setDomainGridlinesVisible(true); localXYPlot.setRangeGridlineStroke(this.defaultLineStroke_); localXYPlot.setRangeGridlinesVisible(true); localXYPlot.setAxisOffset(new RectangleInsets(0.0D, 0.0D, 0.0D, 0.0D)); localXYPlot.setInsets(new RectangleInsets(0.0D, 0.0D, 0.0D, 0.0D), true); }
From source file:org.knime.knip.core.ui.imgviewer.panels.HistogramBC.java
private final void setBackgroundDefault(final JFreeChart chart) { final BasicStroke gridStroke = new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 2.0f, 1.0f }, 0.0f); final XYPlot plot = (XYPlot) chart.getPlot(); plot.setRangeGridlineStroke(gridStroke); plot.setDomainGridlineStroke(gridStroke); // Background of Histogram inside border //plot.setBackgroundPaint(new Color(235,235,235)); plot.setBackgroundPaint(Color.white); // change from white to gray plot.setRangeGridlinePaint(Color.gray); plot.setDomainGridlinePaint(Color.gray); // set lines invisible plot.setDomainGridlinesVisible(false); plot.setRangeGridlinesVisible(false); plot.setOutlineVisible(true);/*from w w w . ja v a 2 s . c o m*/ plot.getDomainAxis().setAxisLineVisible(false); plot.getRangeAxis().setAxisLineVisible(false); plot.getDomainAxis().setLabelPaint(Color.gray); plot.getRangeAxis().setLabelPaint(Color.gray); plot.getDomainAxis().setTickLabelPaint(Color.gray); plot.getRangeAxis().setTickLabelPaint(Color.gray); final TextTitle title = chart.getTitle(); if (title != null) { title.setPaint(Color.black); } }
From source file:com.xpn.xwiki.plugin.charts.ChartCustomizer.java
public static void customizeXYPlot(XYPlot plot, ChartParams params) { customizePlot(plot, params);/* w ww. j a v a 2 s . co m*/ if (params.get(ChartParams.XYPLOT_ORIENTATION) != null) { plot.setOrientation(params.getPlotOrientation(ChartParams.XYPLOT_ORIENTATION)); } if (params.get(ChartParams.AXIS_DOMAIN_PREFIX + ChartParams.PLOTXY_AXIS_GRIDLINE_VISIBLE_SUFFIX) != null) { if (params.getBoolean(ChartParams.AXIS_DOMAIN_PREFIX + ChartParams.PLOTXY_AXIS_GRIDLINE_VISIBLE_SUFFIX) .booleanValue()) { plot.setDomainGridlinesVisible(true); if (params.get( ChartParams.AXIS_DOMAIN_PREFIX + ChartParams.PLOTXY_AXIS_GRIDLINE_COLOR_SUFFIX) != null) { plot.setDomainGridlinePaint(params.getColor( ChartParams.AXIS_DOMAIN_PREFIX + ChartParams.PLOTXY_AXIS_GRIDLINE_COLOR_SUFFIX)); } if (params.get( ChartParams.AXIS_DOMAIN_PREFIX + ChartParams.PLOTXY_AXIS_GRIDLINE_STROKE_SUFFIX) != null) { plot.setDomainGridlineStroke(params.getStroke( ChartParams.AXIS_DOMAIN_PREFIX + ChartParams.PLOTXY_AXIS_GRIDLINE_STROKE_SUFFIX)); } } else { plot.setDomainGridlinesVisible(false); } } if (params.get(ChartParams.AXIS_RANGE_PREFIX + ChartParams.PLOTXY_AXIS_GRIDLINE_VISIBLE_SUFFIX) != null) { if (params.getBoolean(ChartParams.AXIS_RANGE_PREFIX + ChartParams.PLOTXY_AXIS_GRIDLINE_VISIBLE_SUFFIX) .booleanValue()) { plot.setRangeGridlinesVisible(true); if (params.get( ChartParams.AXIS_RANGE_PREFIX + ChartParams.PLOTXY_AXIS_GRIDLINE_COLOR_SUFFIX) != null) { plot.setRangeGridlinePaint(params.getColor( ChartParams.AXIS_RANGE_PREFIX + ChartParams.PLOTXY_AXIS_GRIDLINE_COLOR_SUFFIX)); } if (params.get( ChartParams.AXIS_RANGE_PREFIX + ChartParams.PLOTXY_AXIS_GRIDLINE_STROKE_SUFFIX) != null) { plot.setRangeGridlineStroke(params.getStroke( ChartParams.AXIS_RANGE_PREFIX + ChartParams.PLOTXY_AXIS_GRIDLINE_STROKE_SUFFIX)); } } else { plot.setRangeGridlinesVisible(false); } } if (params.get(ChartParams.XYPLOT_QUADRANT_ORIGIN) != null) { plot.setQuadrantOrigin(params.getPoint2D(ChartParams.XYPLOT_QUADRANT_ORIGIN)); } if (params.get(ChartParams.XYPLOT_QUADRANT_COLORS) != null) { List colors = params.getList(ChartParams.XYPLOT_QUADRANT_COLORS); for (int i = 0; i < 4 && i < colors.size(); i++) { if (colors.get(i) != null) { plot.setQuadrantPaint(i, (Color) colors.get(i)); } } } }
From source file:org.jstockchart.plot.TimeseriesPlot.java
private XYPlot createPricePlot() { Font axisFont = new Font("Arial", 0, 12); Stroke stroke = new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.CAP_SQUARE, 0.0f, new float[] { 1.0f, 1.0f }, 1.0f); PriceArea priceArea = timeseriesArea.getPriceArea(); Color averageColor = new Color(243, 182, 117); priceArea.setAverageColor(averageColor); priceArea.setPriceColor(Color.BLUE); TimeSeriesCollection priceDataset = new TimeSeriesCollection(); priceDataset.addSeries(dataset.getPriceTimeSeries().getTimeSeries()); if (priceArea.isAverageVisible()) { priceDataset.addSeries(dataset.getAverageTimeSeries().getTimeSeries()); }//w ww. j av a 2 s .c om CentralValueAxis logicPriceAxis = priceArea.getLogicPriceAxis(); logicPriceAxis.setTickCount(7); CFXNumberAxis priceAxis = new CFXNumberAxis(logicPriceAxis.getLogicTicks()); priceAxis.setShowUD(true); priceAxis.setOpenPrice(logicPriceAxis.getCentralValue().doubleValue()); priceAxis.setTickMarksVisible(false); XYLineAndShapeRenderer priceRenderer = new XYLineAndShapeRenderer(true, false); priceAxis.setUpperBound(logicPriceAxis.getUpperBound()); priceAxis.setLowerBound(logicPriceAxis.getLowerBound()); priceAxis.setAxisLineVisible(false); priceAxis.setTickLabelFont(axisFont); priceRenderer.setSeriesPaint(0, priceArea.getPriceColor()); priceRenderer.setSeriesPaint(1, priceArea.getAverageColor()); CFXNumberAxis rateAxis = new CFXNumberAxis(logicPriceAxis.getRatelogicTicks()); rateAxis.setShowUD(true); rateAxis.setOpenPrice(logicPriceAxis.getCentralValue().doubleValue()); rateAxis.setTickMarksVisible(false); ; rateAxis.setTickLabelFont(axisFont); rateAxis.setAxisLineVisible(false); rateAxis.setUpperBound(logicPriceAxis.getUpperBound()); rateAxis.setLowerBound(logicPriceAxis.getLowerBound()); XYPlot plot = new XYPlot(priceDataset, null, priceAxis, priceRenderer); plot.setBackgroundPaint(priceArea.getBackgroudColor()); plot.setOrientation(priceArea.getOrientation()); plot.setRangeAxisLocation(priceArea.getPriceAxisLocation()); plot.setRangeMinorGridlinesVisible(false); Stroke outLineStroke = new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.CAP_SQUARE, 0.0f, new float[] { 1.0f, 1.0f }, 1.0f); Stroke gridLineStroke = new BasicStroke(0.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0.0f, new float[] { 2.0f, 2.0f }, 1.0f); plot.setRangeGridlineStroke(gridLineStroke); plot.setDomainGridlineStroke(gridLineStroke); plot.setRangeGridlinesVisible(true); plot.setDomainGridlinesVisible(true); plot.setOutlineVisible(true); plot.setOutlineStroke(outLineStroke); plot.setOutlinePaint(Color.BLACK); if (priceArea.isRateVisible()) { plot.setRangeAxis(1, rateAxis); plot.setRangeAxisLocation(1, priceArea.getRateAxisLocation()); plot.setDataset(1, null); plot.mapDatasetToRangeAxis(1, 1); } if (priceArea.isMarkCentralValue()) { Number centralPrice = logicPriceAxis.getCentralValue(); if (centralPrice != null) { plot.addRangeMarker(new ValueMarker(centralPrice.doubleValue(), priceArea.getCentralPriceColor(), new BasicStroke())); } } return plot; }
From source file:org.gwaspi.gui.reports.SampleQAHetzygPlotZoom.java
private JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createScatterPlot("Heterozygosity vs. Missing Ratio", "Heterozygosity Ratio", "Missing Ratio", dataset, PlotOrientation.VERTICAL, true, false, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setNoDataMessage("NO DATA"); plot.setDomainZeroBaselineVisible(true); plot.setRangeZeroBaselineVisible(true); // CHART BACKGROUD COLOR chart.setBackgroundPaint(Color.getHSBColor(0.1f, 0.1f, 1.0f)); // Hue, saturation, brightness plot.setBackgroundPaint(PLOT_MANHATTAN_BACKGROUND); // Hue, saturation, brightness 9 // GRIDLINES/*from w w w .java 2 s . c o m*/ plot.setDomainGridlineStroke(new BasicStroke(0.0f)); plot.setDomainMinorGridlineStroke(new BasicStroke(0.0f)); plot.setDomainGridlinePaint(PLOT_MANHATTAN_BACKGROUND.darker().darker()); // Hue, saturation, brightness 7 plot.setDomainMinorGridlinePaint(PLOT_MANHATTAN_BACKGROUND); // Hue, saturation, brightness 9 plot.setRangeGridlineStroke(new BasicStroke(0.0f)); plot.setRangeMinorGridlineStroke(new BasicStroke(0.0f)); plot.setRangeGridlinePaint(PLOT_MANHATTAN_BACKGROUND.darker().darker()); // Hue, saturation, brightness 7 plot.setRangeMinorGridlinePaint(PLOT_MANHATTAN_BACKGROUND.darker()); // Hue, saturation, brightness 8 plot.setDomainMinorGridlinesVisible(true); plot.setRangeMinorGridlinesVisible(true); // DOTS RENDERER XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setSeriesPaint(0, PLOT_MANHATTAN_DOTS); // renderer.setSeriesOutlinePaint(0, Color.DARK_GRAY); // renderer.setUseOutlinePaint(true); // Set dot shape of the currently appended Series renderer.setSeriesShape(0, new Rectangle2D.Double(-1, -1, 2, 2)); renderer.setSeriesVisibleInLegend(0, false); // AXIS double maxHetzy = 0.005; for (int i = 0; i < dataset.getItemCount(0); i++) { if (maxHetzy < dataset.getXValue(0, i)) { maxHetzy = dataset.getXValue(0, i); } } NumberAxis hetzyAxis = (NumberAxis) plot.getDomainAxis(); hetzyAxis.setAutoRangeIncludesZero(true); hetzyAxis.setAxisLineVisible(true); hetzyAxis.setTickLabelsVisible(true); hetzyAxis.setTickMarksVisible(true); hetzyAxis.setRange(0, maxHetzy * 1.1); double maxMissrat = 0.005; for (int i = 0; i < dataset.getItemCount(0); i++) { if (maxMissrat < dataset.getYValue(0, i)) { maxMissrat = dataset.getYValue(0, i); } } NumberAxis missratAxis = (NumberAxis) plot.getRangeAxis(); missratAxis.setAutoRangeIncludesZero(true); missratAxis.setAxisLineVisible(true); missratAxis.setTickLabelsVisible(true); missratAxis.setTickMarksVisible(true); missratAxis.setRange(0, maxMissrat * 1.1); // Add significance Threshold to subplot final Marker missingThresholdLine = new ValueMarker(missingThreshold); missingThresholdLine.setPaint(Color.blue); final Marker hetzyThresholdLine = new ValueMarker(hetzyThreshold); hetzyThresholdLine.setPaint(Color.blue); // Add legend to hetzyThreshold hetzyThresholdLine.setLabel("hetzyg. threshold = " + hetzyThreshold); missingThresholdLine.setLabel("missing. threshold = " + missingThreshold); hetzyThresholdLine.setLabelAnchor(RectangleAnchor.TOP_LEFT); hetzyThresholdLine.setLabelTextAnchor(TextAnchor.TOP_RIGHT); missingThresholdLine.setLabelAnchor(RectangleAnchor.BOTTOM_LEFT); missingThresholdLine.setLabelTextAnchor(TextAnchor.TOP_LEFT); plot.addRangeMarker(missingThresholdLine); // THIS FOR MISSING RATIO plot.addDomainMarker(hetzyThresholdLine); // THIS FOR HETZY RATIO // Marker label if below hetzyThreshold XYItemRenderer lblRenderer = plot.getRenderer(); // THRESHOLD AND SELECTED LABEL GENERATOR MySeriesItemLabelGenerator lblGenerator = new MySeriesItemLabelGenerator(hetzyThreshold, missingThreshold); lblRenderer.setSeriesItemLabelGenerator(0, lblGenerator); lblRenderer.setSeriesItemLabelFont(0, new Font("SansSerif", Font.PLAIN, 10)); lblRenderer.setSeriesPositiveItemLabelPosition(0, new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.BOTTOM_LEFT, TextAnchor.BOTTOM_LEFT, 2 * Math.PI)); // TOOLTIP GENERATOR MyXYToolTipGenerator tooltipGenerator = new MyXYToolTipGenerator(); lblRenderer.setBaseToolTipGenerator(tooltipGenerator); lblRenderer.setSeriesItemLabelsVisible(0, true); return chart; }
From source file:ucar.unidata.idv.control.chart.ChartHolder.java
/** * apply props//from w w w . j av a 2 s. c o m */ protected void applyPlotProperties() { if (plot == null) { return; } if (dataAreaColor != null) { plot.setBackgroundPaint(dataAreaColor); } if (backgroundColor != null) { chart.setBackgroundPaint(backgroundColor); } if ((backgroundColor != null) && (chartPanel != null)) { chartPanel.setBackground(backgroundColor); } if (showTitle) { chart.setTitle(getName()); } else { chart.setTitle((String) null); } if (plot instanceof XYPlot) { final XYPlot p = (XYPlot) plot; p.setDomainGridlinesVisible(domainLineState.getVisible()); p.setRangeGridlinesVisible(rangeLineState.getVisible()); p.setDomainGridlinePaint(domainLineState.getColor()); p.setRangeGridlinePaint(rangeLineState.getColor()); p.setDomainGridlineStroke(domainLineState.getStroke()); p.setRangeGridlineStroke(rangeLineState.getStroke()); if (p.getDomainAxis() instanceof DateAxis && dateFormat != null) { final DateAxis ax = (DateAxis) p.getDomainAxis(); final TimeZone tz = getChartManager().getControl().getIdv().getPreferenceManager() .getDefaultTimeZone(); final DateFormat df = new SimpleDateFormat(dateFormat); df.setTimeZone(tz); ax.setDateFormatOverride(df); } } }
From source file:org.jstockchart.plot.TimeseriesPlot.java
private XYPlot createVolumePlot() { Font axisFont = new Font("Arial", 0, 12); Stroke stroke = new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.CAP_SQUARE, 0.0f, new float[] { 1.0f, 1.0f }, 1.0f); VolumeArea volumeArea = timeseriesArea.getVolumeArea(); LogicNumberAxis logicVolumeAxis = volumeArea.getLogicVolumeAxis(); Color volumeColor = new Color(86, 126, 160); volumeArea.setVolumeColor(volumeColor); CFXNumberAxis volumeAxis = new CFXNumberAxis(logicVolumeAxis.getLogicTicks()); volumeAxis.setAxisLineVisible(false); volumeAxis.setCustomTickCount(2);/*from w w w . ja v a 2 s . c om*/ volumeAxis.setTickLabelPaint(volumeColor); volumeAxis.setUpperBound(logicVolumeAxis.getUpperBound()); volumeAxis.setTickLabelFont(axisFont); volumeAxis.setTickMarkStroke(stroke); volumeAxis.setLowerBound(logicVolumeAxis.getLowerBound()); volumeAxis.setAutoRangeIncludesZero(true); XYAreaRenderer2 volumeRenderer = new XYAreaRenderer2(); volumeRenderer.setSeriesPaint(0, volumeArea.getVolumeColor()); //volumeRenderer.setShadowVisible(false); volumeRenderer.setSeriesStroke(0, stroke); volumeRenderer.setBaseStroke(stroke); XYPlot plot = new XYPlot(new TimeSeriesCollection(dataset.getVolumeTimeSeries()), null, volumeAxis, volumeRenderer); plot.setBackgroundPaint(volumeArea.getBackgroudColor()); plot.setOrientation(volumeArea.getOrientation()); plot.setRangeAxisLocation(volumeArea.getVolumeAxisLocation()); plot.setRangeMinorGridlinesVisible(false); Stroke outLineStroke = new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.CAP_SQUARE, 0.0f, new float[] { 1.0f, 1.0f }, 1.0f); Stroke gridLineStroke = new BasicStroke(0.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0.0f, new float[] { 2.0f, 2.0f }, 1.0f); // plot.setBackgroundPaint(Color.RED); plot.setRangeGridlineStroke(gridLineStroke); plot.setDomainGridlineStroke(gridLineStroke); plot.setRangeGridlinesVisible(true); plot.setDomainGridlinesVisible(true); plot.setOutlineVisible(true); plot.setOutlineStroke(outLineStroke); plot.setOutlinePaint(Color.black); plot.setRangeZeroBaselineVisible(true); return plot; }
From source file:org.gwaspi.gui.reports.ManhattanPlotZoom.java
private JFreeChart createChart(XYDataset dataset, ChromosomeKey chr) { JFreeChart chart = ChartFactory.createScatterPlot(null, "", "P value", dataset, PlotOrientation.VERTICAL, true, false, false);/*from w ww. ja va 2 s. c o m*/ XYPlot plot = (XYPlot) chart.getPlot(); plot.setNoDataMessage("NO DATA"); plot.setDomainZeroBaselineVisible(true); plot.setRangeZeroBaselineVisible(true); // CHART BACKGROUD COLOR chart.setBackgroundPaint(Color.getHSBColor(0.1f, 0.1f, 1.0f)); // Hue, saturation, brightness plot.setBackgroundPaint(manhattan_back); // Hue, saturation, brightness 9 // GRIDLINES plot.setDomainGridlineStroke(new BasicStroke(0.0f)); plot.setDomainMinorGridlineStroke(new BasicStroke(0.0f)); plot.setDomainGridlinePaint(manhattan_back.darker().darker()); // Hue, saturation, brightness 7 plot.setDomainMinorGridlinePaint(manhattan_back); // Hue, saturation, brightness 9 plot.setRangeGridlineStroke(new BasicStroke(0.0f)); plot.setRangeMinorGridlineStroke(new BasicStroke(0.0f)); plot.setRangeGridlinePaint(manhattan_back.darker().darker()); // Hue, saturation, brightness 7 plot.setRangeMinorGridlinePaint(manhattan_back.darker()); // Hue, saturation, brightness 8 plot.setDomainMinorGridlinesVisible(true); plot.setRangeMinorGridlinesVisible(true); // DOTS RENDERER XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setSeriesPaint(0, manhattan_dot); // renderer.setSeriesOutlinePaint(0, Color.DARK_GRAY); // renderer.setUseOutlinePaint(true); // Set dot shape of the currently appended Series renderer.setSeriesShape(0, new Rectangle2D.Double(0.0, 0.0, 2, 2)); renderer.setSeriesVisibleInLegend(0, false); NumberAxis positionAxis = (NumberAxis) plot.getDomainAxis(); // domainAxis.setAutoRangeIncludesZero(false); // domainAxis.setTickMarkInsideLength(2.0f); // domainAxis.setTickMarkOutsideLength(2.0f); // domainAxis.setMinorTickCount(2); // domainAxis.setMinorTickMarksVisible(true); positionAxis.setLabelAngle(1.0); positionAxis.setAutoRangeIncludesZero(false); positionAxis.setAxisLineVisible(true); positionAxis.setTickLabelsVisible(true); positionAxis.setTickMarksVisible(true); // ADD INVERSE LOG(10) Y AXIS LogAxis logPAxis = new LogAxis("P value"); logPAxis.setBase(10); logPAxis.setInverted(true); logPAxis.setNumberFormatOverride(GenericReportGenerator.FORMAT_P_VALUE); logPAxis.setTickMarkOutsideLength(2.0f); logPAxis.setMinorTickCount(2); logPAxis.setMinorTickMarksVisible(true); logPAxis.setAxisLineVisible(true); logPAxis.setUpperMargin(0); TickUnitSource units = NumberAxis.createIntegerTickUnits(); logPAxis.setStandardTickUnits(units); plot.setRangeAxis(0, logPAxis); // Add significance Threshold to subplot //threshold = 0.5/rdMatrixMetadata.getMarkerSetSize(); // (0.05/10? SNPs => 5*10-?) final Marker thresholdLine = new ValueMarker(threshold); thresholdLine.setPaint(Color.red); // Add legend to threshold thresholdLine.setLabel("P = " + GenericReportGenerator.FORMAT_P_VALUE.format(threshold)); thresholdLine.setLabelAnchor(RectangleAnchor.TOP_RIGHT); thresholdLine.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT); plot.addRangeMarker(thresholdLine); // Marker label if below threshold XYItemRenderer lblRenderer = plot.getRenderer(); // THRESHOLD AND SELECTED LABEL GENERATOR MySeriesItemLabelGenerator lblGenerator = new MySeriesItemLabelGenerator(threshold, chr); lblRenderer.setSeriesItemLabelGenerator(0, lblGenerator); lblRenderer.setSeriesItemLabelFont(0, new Font("SansSerif", Font.PLAIN, 12)); lblRenderer.setSeriesPositiveItemLabelPosition(0, new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.TOP_LEFT, TextAnchor.BOTTOM_LEFT, Math.PI / 4.0)); // TOOLTIP GENERATOR MyXYToolTipGenerator tooltipGenerator = new MyXYToolTipGenerator(chr); lblRenderer.setBaseToolTipGenerator(tooltipGenerator); lblRenderer.setSeriesItemLabelsVisible(0, true); return chart; }
From source file:ucar.unidata.idv.control.chart.PlotWrapper.java
/** * Utility to init xy plots/*from w ww. j av a 2 s .co m*/ * * @param plot the plotx */ protected void initXYPlot(XYPlot plot) { plot.setBackgroundPaint(dataAreaColor); // plot.setAxisOffset(new RectangleInsets(6.0, 3.0, 3.0, 3.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.setDomainGridlinesVisible(domainLineState.getVisible()); plot.setRangeGridlinesVisible(rangeLineState.getVisible()); plot.setDomainGridlinePaint(domainLineState.getColor()); plot.setRangeGridlinePaint(rangeLineState.getColor()); plot.setDomainGridlineStroke(domainLineState.getStroke()); plot.setRangeGridlineStroke(rangeLineState.getStroke()); }