Java Code Examples for org.jfree.chart.plot.XYPlot#setRangeGridlinesVisible()

The following examples show how to use org.jfree.chart.plot.XYPlot#setRangeGridlinesVisible() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BeltDateTimeColumnStatisticsModel.java    From rapidminer-studio with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Creates the histogram chart.
 */
private JFreeChart createHistogramChart(final Table table) {
	JFreeChart chart = ChartFactory.createHistogram(null, null, null, createHistogramDataset(table),
			PlotOrientation.VERTICAL, false, false, false);
	setDefaultChartFonts(chart);
	chart.setBackgroundPaint(null);
	chart.setBackgroundImageAlpha(0.0f);

	XYPlot plot = (XYPlot) chart.getPlot();
	plot.setRangeGridlinesVisible(false);
	plot.setDomainGridlinesVisible(false);
	plot.setOutlineVisible(false);
	plot.setRangeZeroBaselineVisible(false);
	plot.setDomainZeroBaselineVisible(false);
	plot.getDomainAxis().setTickLabelsVisible(false);
	plot.setBackgroundPaint(COLOR_INVISIBLE);
	plot.setBackgroundImageAlpha(0.0f);

	XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer();
	renderer.setSeriesPaint(0, AttributeGuiTools.getColorForValueType(Ontology.DATE_TIME));
	renderer.setBarPainter(new StandardXYBarPainter());
	renderer.setDrawBarOutline(true);
	renderer.setShadowVisible(false);

	return chart;
}
 
Example 2
Source File: BeltNumericalColumnStatisticsModel.java    From rapidminer-studio with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Creates the histogram chart.
 */
private JFreeChart createHistogramChart(Table table) {
	JFreeChart chart = ChartFactory.createHistogram(null, null, null, createHistogramDataset(table),
			PlotOrientation.VERTICAL, false, false, false);
	AbstractAttributeStatisticsModel.setDefaultChartFonts(chart);
	chart.setBackgroundPaint(null);
	chart.setBackgroundImageAlpha(0.0f);

	XYPlot plot = (XYPlot) chart.getPlot();
	plot.setRangeGridlinesVisible(false);
	plot.setDomainGridlinesVisible(false);
	plot.setOutlineVisible(false);
	plot.setRangeZeroBaselineVisible(false);
	plot.setDomainZeroBaselineVisible(false);
	plot.setBackgroundPaint(COLOR_INVISIBLE);
	plot.setBackgroundImageAlpha(0.0f);

	XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer();
	renderer.setSeriesPaint(0, AttributeGuiTools.getColorForValueType(Ontology.NUMERICAL));
	renderer.setBarPainter(new StandardXYBarPainter());
	renderer.setDrawBarOutline(true);
	renderer.setShadowVisible(false);

	return chart;
}
 
Example 3
Source File: BeltTimeColumnStatisticsModel.java    From rapidminer-studio with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Creates the histogram chart.
 */
private JFreeChart createHistogramChart(final Table table) {
	JFreeChart chart = ChartFactory.createHistogram(null, null, null, createHistogramDataset(table),
			PlotOrientation.VERTICAL, false, false, false);
	setDefaultChartFonts(chart);
	chart.setBackgroundPaint(null);
	chart.setBackgroundImageAlpha(0.0f);

	XYPlot plot = (XYPlot) chart.getPlot();
	plot.setRangeGridlinesVisible(false);
	plot.setDomainGridlinesVisible(false);
	plot.setOutlineVisible(false);
	plot.setRangeZeroBaselineVisible(false);
	plot.setDomainZeroBaselineVisible(false);
	plot.getDomainAxis().setTickLabelsVisible(false);
	plot.setBackgroundPaint(COLOR_INVISIBLE);
	plot.setBackgroundImageAlpha(0.0f);

	XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer();
	renderer.setSeriesPaint(0, AttributeGuiTools.getColorForValueType(Ontology.DATE_TIME));
	renderer.setBarPainter(new StandardXYBarPainter());
	renderer.setDrawBarOutline(true);
	renderer.setShadowVisible(false);

	return chart;
}
 
Example 4
Source File: DateTimeAttributeStatisticsModel.java    From rapidminer-studio with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Creates the histogram chart.
 *
 * @param exampleSet
 * @return
 */
private JFreeChart createHistogramChart(final ExampleSet exampleSet) {
	JFreeChart chart = ChartFactory.createHistogram(null, null, null, createHistogramDataset(exampleSet),
			PlotOrientation.VERTICAL, false, false, false);
	AbstractAttributeStatisticsModel.setDefaultChartFonts(chart);
	chart.setBackgroundPaint(null);
	chart.setBackgroundImageAlpha(0.0f);

	XYPlot plot = (XYPlot) chart.getPlot();
	plot.setRangeGridlinesVisible(false);
	plot.setDomainGridlinesVisible(false);
	plot.setOutlineVisible(false);
	plot.setRangeZeroBaselineVisible(false);
	plot.setDomainZeroBaselineVisible(false);
	plot.getDomainAxis().setTickLabelsVisible(false);
	plot.setBackgroundPaint(COLOR_INVISIBLE);
	plot.setBackgroundImageAlpha(0.0f);

	XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer();
	renderer.setSeriesPaint(0, AttributeGuiTools.getColorForValueType(Ontology.DATE_TIME));
	renderer.setBarPainter(new StandardXYBarPainter());
	renderer.setDrawBarOutline(true);
	renderer.setShadowVisible(false);

	return chart;
}
 
Example 5
Source File: NumericalAttributeStatisticsModel.java    From rapidminer-studio with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Creates the histogram chart.
 *
 * @param exampleSet
 * @return
 */
private JFreeChart createHistogramChart(ExampleSet exampleSet) {
	JFreeChart chart = ChartFactory.createHistogram(null, null, null, createHistogramDataset(exampleSet),
			PlotOrientation.VERTICAL, false, false, false);
	AbstractAttributeStatisticsModel.setDefaultChartFonts(chart);
	chart.setBackgroundPaint(null);
	chart.setBackgroundImageAlpha(0.0f);

	XYPlot plot = (XYPlot) chart.getPlot();
	plot.setRangeGridlinesVisible(false);
	plot.setDomainGridlinesVisible(false);
	plot.setOutlineVisible(false);
	plot.setRangeZeroBaselineVisible(false);
	plot.setDomainZeroBaselineVisible(false);
	plot.setBackgroundPaint(COLOR_INVISIBLE);
	plot.setBackgroundImageAlpha(0.0f);

	XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer();
	renderer.setSeriesPaint(0, AttributeGuiTools.getColorForValueType(Ontology.NUMERICAL));
	renderer.setBarPainter(new StandardXYBarPainter());
	renderer.setDrawBarOutline(true);
	renderer.setShadowVisible(false);

	return chart;
}
 
Example 6
Source File: ChartManager.java    From jamel with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates and returns a new plot with the specified dataset, axes and
 * renderer.
 * 
 * @param dataset
 *            the dataset (<code>null</code> permitted).
 * @param xAxis
 *            the x axis (<code>null</code> permitted).
 * @param yAxis
 *            the y axis (<code>null</code> permitted).
 * @param renderer
 *            the renderer (<code>null</code> permitted).
 * @return a new plot.
 */
private static XYPlot createXYPlot(XYDataset dataset, NumberAxis xAxis, NumberAxis yAxis, XYItemRenderer renderer) {
	final XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
	plot.setOrientation(PlotOrientation.VERTICAL);
	plot.setDomainGridlinesVisible(false);
	plot.setDomainMinorGridlinesVisible(false);
	plot.setRangeGridlinesVisible(false);
	plot.setRangeMinorGridlinesVisible(false);
	plot.setRangeCrosshairVisible(false);
	plot.setDomainCrosshairVisible(false);
	plot.setBackgroundPaint(Color.white);
	// plot.getRangeAxis().setLabelFont(axisLabelFont);
	// plot.getDomainAxis().setLabelFont(axisLabelFont);
	plot.setDomainZeroBaselineVisible(true);
	plot.setRangeZeroBaselineVisible(true);
	return plot;
}
 
Example 7
Source File: SimpleScatterPlot.java    From mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
public SimpleScatterPlot(double[] xValues, double[] yValues, double[] colors, String xLabel,
    String yLabel) {
  super(null);

  // setBackground(Color.white);
  setCursor(Cursor.CROSSHAIR);

  xAxis = new NumberAxis(xLabel);
  xAxis.setAutoRangeIncludesZero(false);
  xAxis.setUpperMargin(0);
  xAxis.setLowerMargin(0);

  yAxis = new NumberAxis(yLabel);
  yAxis.setAutoRangeIncludesZero(false);
  yAxis.setUpperMargin(0);
  yAxis.setLowerMargin(0);

  xyDataset = new DefaultXYZDataset();
  int length = Math.min(xValues.length, yValues.length);
  double[][] data = new double[3][length];
  System.arraycopy(xValues, 0, data[0], 0, length);
  System.arraycopy(yValues, 0, data[1], 0, length);
  System.arraycopy(colors, 0, data[2], 0, length);
  xyDataset.addSeries(SERIES_ID, data);

  XYDotRenderer renderer = new XYDotRenderer() {
    @Override
    public Paint getItemPaint(int row, int col) {
      double c = xyDataset.getZ(row, col).doubleValue();
      return Color.getHSBColor((float) c, 1.0f, 1.0f);
    }
  };

  renderer.setDotHeight(3);
  renderer.setDotWidth(3);

  plot = new XYPlot(xyDataset, xAxis, yAxis, renderer);
  plot.setBackgroundPaint(Color.white);
  plot.setDomainGridlinesVisible(true);
  plot.setRangeGridlinesVisible(true);

  chart = new JFreeChart("", new Font("SansSerif", Font.BOLD, 12), plot, false);
  chart.setBackgroundPaint(Color.white);

  super.setChart(chart);

  // reset zoom history
  ZoomHistory history = getZoomHistory();
  if (history != null)
    history.clear();
}
 
Example 8
Source File: PlotUtil.java    From dl4j-tutorials with MIT License 4 votes vote down vote up
private static JFreeChart createChart(XYZDataset dataset, double[] mins, double[] maxs, int nPoints, XYDataset xyData) {
    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;
}
 
Example 9
Source File: SimpleScatterPlot.java    From mzmine2 with GNU General Public License v2.0 4 votes vote down vote up
public SimpleScatterPlot(double[] xValues, double[] yValues, double[] colors, String xLabel,
    String yLabel) {
  super(null, true);

  setBackground(Color.white);
  setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));

  xAxis = new NumberAxis(xLabel);
  xAxis.setAutoRangeIncludesZero(false);
  xAxis.setUpperMargin(0);
  xAxis.setLowerMargin(0);

  yAxis = new NumberAxis(yLabel);
  yAxis.setAutoRangeIncludesZero(false);
  yAxis.setUpperMargin(0);
  yAxis.setLowerMargin(0);

  xyDataset = new DefaultXYZDataset();
  int length = Math.min(xValues.length, yValues.length);
  double[][] data = new double[3][length];
  System.arraycopy(xValues, 0, data[0], 0, length);
  System.arraycopy(yValues, 0, data[1], 0, length);
  System.arraycopy(colors, 0, data[2], 0, length);
  xyDataset.addSeries(SERIES_ID, data);

  XYDotRenderer renderer = new XYDotRenderer() {
    @Override
    public Paint getItemPaint(int row, int col) {
      double c = xyDataset.getZ(row, col).doubleValue();
      return Color.getHSBColor((float) c, 1.0f, 1.0f);
    }
  };

  renderer.setDotHeight(3);
  renderer.setDotWidth(3);

  plot = new XYPlot(xyDataset, xAxis, yAxis, renderer);
  plot.setBackgroundPaint(Color.white);
  plot.setDomainGridlinesVisible(true);
  plot.setRangeGridlinesVisible(true);

  chart = new JFreeChart("", new Font("SansSerif", Font.BOLD, 12), plot, false);
  chart.setBackgroundPaint(Color.white);

  super.setChart(chart);

  // reset zoom history
  ZoomHistory history = getZoomHistory();
  if (history != null)
    history.clear();
}
 
Example 10
Source File: ChartJFreeChartOutputScatter.java    From gama with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void initChart(final IScope scope, final String chartname) {
	super.initChart(scope, chartname);

	final XYPlot pp = (XYPlot) chart.getPlot();
	pp.setDomainGridlinePaint(axesColor);
	pp.setRangeGridlinePaint(axesColor);
	pp.setDomainCrosshairPaint(axesColor);
	pp.setRangeCrosshairPaint(axesColor);
	pp.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
	pp.setDomainCrosshairVisible(false);
	pp.setRangeCrosshairVisible(false);

	pp.getDomainAxis().setAxisLinePaint(axesColor);
	pp.getDomainAxis().setTickLabelFont(getTickFont());
	pp.getDomainAxis().setLabelFont(getLabelFont());
	if (textColor != null) {
		pp.getDomainAxis().setLabelPaint(textColor);
		pp.getDomainAxis().setTickLabelPaint(textColor);
	}

	NumberAxis axis = (NumberAxis) pp.getRangeAxis();
	axis = formatYAxis(scope, axis);
	pp.setRangeAxis(axis);
	if (ytickunit > 0) {
		((NumberAxis) pp.getRangeAxis()).setTickUnit(new NumberTickUnit(ytickunit));
		pp.setRangeGridlinesVisible(true);
	} else {
		pp.setRangeGridlinesVisible(GamaPreferences.Displays.CHART_GRIDLINES.getValue());
	}

	// resetAutorange(scope);

	if (getType() == ChartOutput.SERIES_CHART) {
		if (xlabel == null) {
			xlabel = "time";
		}
	}
	if (getType() == ChartOutput.XY_CHART) {}
	if (getType() == ChartOutput.SCATTER_CHART) {}
	if (!this.getXTickValueVisible(scope)) {
		pp.getDomainAxis().setTickMarksVisible(false);
		pp.getDomainAxis().setTickLabelsVisible(false);

	}

}
 
Example 11
Source File: ChartJFreeChartOutputHeatmap.java    From gama with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void initChart(final IScope scope, final String chartname) {
	super.initChart(scope, chartname);

	final XYPlot pp = (XYPlot) chart.getPlot();
	pp.setDomainGridlinePaint(axesColor);
	pp.setRangeGridlinePaint(axesColor);
	pp.setDomainCrosshairPaint(axesColor);
	pp.setRangeCrosshairPaint(axesColor);
	pp.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
	pp.setDomainCrosshairVisible(false);
	pp.setRangeCrosshairVisible(false);
	pp.setRangeGridlinesVisible(false);
	pp.setDomainGridlinesVisible(false);

	pp.getDomainAxis().setAxisLinePaint(axesColor);

	pp.getDomainAxis().setTickLabelFont(getTickFont());
	pp.getDomainAxis().setLabelFont(getLabelFont());
	if (textColor != null) {
		pp.getDomainAxis().setLabelPaint(textColor);
		pp.getDomainAxis().setTickLabelPaint(textColor);
	}
	if (xtickunit > 0) {
		((NumberAxis) pp.getDomainAxis()).setTickUnit(new NumberTickUnit(xtickunit));
	}

	pp.getRangeAxis().setAxisLinePaint(axesColor);
	pp.getRangeAxis().setLabelFont(getLabelFont());
	pp.getRangeAxis().setTickLabelFont(getTickFont());
	if (textColor != null) {
		pp.getRangeAxis().setLabelPaint(textColor);
		pp.getRangeAxis().setTickLabelPaint(textColor);
	}
	if (ytickunit > 0) {
		((NumberAxis) pp.getRangeAxis()).setTickUnit(new NumberTickUnit(ytickunit));
	}

	// resetAutorange(scope);

	if (xlabel != null && !xlabel.isEmpty()) {
		pp.getDomainAxis().setLabel(xlabel);
	}
	if (ylabel != null && !ylabel.isEmpty()) {
		pp.getRangeAxis().setLabel(ylabel);
	}

}
 
Example 12
Source File: AnomalyGraphGenerator.java    From incubator-pinot with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a chart containing the current/baseline data (in that order) as well as markers for
 * each anomaly interval. timeGranularity and windowMillis are used to determine the date format
 * and spacing for tick marks on the domain (x) axis.
 */
public JFreeChart createChart(final XYDataset dataset, final String metric,
    final TimeGranularity timeGranularity, final long windowMillis,
    final Map<MergedAnomalyResultDTO, String> anomaliesWithLabels) {

  // create the chart...
  final JFreeChart chart = ChartFactory.createTimeSeriesChart(null, // no chart title for email
                                                                    // image
      "Date (" + DEFAULT_TIME_ZONE.getID() + ")", // x axis label
      metric, // y axis label
      dataset, // data
      true, // include legend
      false, // tooltips - n/a if the chart will be saved as an img
      false // urls - n/a if the chart will be saved as an img
  );

  // get a reference to the plot for further customisation...
  final XYPlot plot = chart.getXYPlot();
  plot.setBackgroundPaint(Color.white);
  plot.setDomainGridlinesVisible(false);
  plot.setRangeGridlinesVisible(false);

  // dashboard webapp currently uses solid blue for current and dashed blue for baseline
  // (5/2/2016)
  final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
  renderer.setSeriesShapesVisible(0, false);
  renderer.setSeriesShapesVisible(1, false);
  renderer.setSeriesPaint(0, Color.BLUE);
  renderer.setSeriesPaint(1, Color.BLUE);
  // http://www.java2s.com/Code/Java/Chart/JFreeChartLineChartDemo5showingtheuseofacustomdrawingsupplier.htm
  // set baseline to be dashed
  renderer.setSeriesStroke(1,
      new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] {
          2.0f, 6.0f
      }, 0.0f));
  plot.setRenderer(renderer);

  DateAxis axis = (DateAxis) plot.getDomainAxis();
  DateTickUnit dateTickUnit = getDateTickUnit(timeGranularity, windowMillis);
  SimpleDateFormat dateFormat = getDateFormat(timeGranularity);
  axis.setDateFormatOverride(dateFormat);
  axis.setTickUnit(dateTickUnit);
  axis.setVerticalTickLabels(true);

  List<Marker> anomalyIntervals = getAnomalyIntervals(anomaliesWithLabels);
  for (Marker marker : anomalyIntervals) {
    plot.addDomainMarker(marker);
  }

  return chart;

}