private XYPlot createScalabilityPlot(List<XYSeries> seriesList, String xAxisLabel, NumberFormat xAxisNumberFormat, String yAxisLabel, NumberFormat yAxisNumberFormat) { NumberAxis xAxis; if (useLogarithmicProblemScale(seriesList)) { LogarithmicAxis logarithmicAxis = new LogarithmicAxis(xAxisLabel + " (logarithmic)"); logarithmicAxis.setAllowNegativesFlag(true); xAxis = logarithmicAxis; } else { xAxis = new NumberAxis(xAxisLabel); } xAxis.setNumberFormatOverride(xAxisNumberFormat); NumberAxis yAxis = new NumberAxis(yAxisLabel); yAxis.setNumberFormatOverride(yAxisNumberFormat); XYPlot plot = new XYPlot(null, xAxis, yAxis, null); int seriesIndex = 0; for (XYSeries series : seriesList) { XYSeriesCollection seriesCollection = new XYSeriesCollection(); seriesCollection.addSeries(series); plot.setDataset(seriesIndex, seriesCollection); XYItemRenderer renderer = createScalabilityPlotRenderer(yAxisNumberFormat); plot.setRenderer(seriesIndex, renderer); seriesIndex++; } plot.setOrientation(PlotOrientation.VERTICAL); return plot; }
/** * Zooms in on the current range. * * @param lowerPercent the new lower bound. * @param upperPercent the new upper bound. */ @Override public void zoomRange(double lowerPercent, double upperPercent) { double startLog = switchedLog10(getRange().getLowerBound()); double lengthLog = switchedLog10(getRange().getUpperBound()) - startLog; Range adjusted; if (isInverted()) { adjusted = new Range( switchedPow10(startLog + (lengthLog * (1 - upperPercent))), switchedPow10(startLog + (lengthLog * (1 - lowerPercent)))); } else { adjusted = new Range( switchedPow10(startLog + (lengthLog * lowerPercent)), switchedPow10(startLog + (lengthLog * upperPercent))); } setRange(adjusted); }
/** * Returns the log10 value, depending on if values between 0 and * 1 are being plotted. If negative values are not allowed and * the lower bound is between 0 and 10 then a normal log is * returned; otherwise the returned value is adjusted if the * given value is less than 10. * * @param val the value. * * @return log<sub>10</sub>(val). * * @see #switchedPow10(double) */ protected double switchedLog10(double val) { return this.smallLogFlag ? Math.log(val) / LOG10_VALUE : adjustedLog10(val); }
private JFreeChart createChart(String title, XYDataset magDataset, String freqUnits, String magnitudeUnits) { XYItemRenderer renderer1 = new StandardXYItemRenderer(); NumberAxis rangeAxis1 = new NumberAxis("Magnitude " + magnitudeUnits); XYPlot subplot1 = new XYPlot(magDataset, new LogarithmicAxis("Frequency " + freqUnits), rangeAxis1, renderer1); subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); renderer1.setSeriesVisibleInLegend(0, false); return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, subplot1, true); } }
public static JFreeChart createStatisticalBarChart(CategoryDataset dataset) { final CategoryAxis xAxis = new CategoryAxis("Type"); xAxis.setLowerMargin(0.01d); // percentage of space before first bar xAxis.setUpperMargin(0.01d); // percentage of space after last bar xAxis.setCategoryMargin(0.3d); // percentage of space between // categories xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); final LogarithmicAxis yAxis = new LogarithmicAxis("Time (s)");//new NumberAxis("Value"); yAxis.setAutoRange(true); //yAxis.setAutoRangeMinimumSize(/size); yAxis.setLowerBound(0.0001); yAxis.setMinorTickMarksVisible(true); yAxis.setAutoRangeIncludesZero(false); yAxis.setStrictValuesFlag(false); // define the plot final CategoryItemRenderer renderer = new StatisticalBarRenderer(); final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer); final JFreeChart chart = new JFreeChart("Performance Comparison", new Font("Helvetica", Font.BOLD, 14), plot, true); return chart; }
public void autoAdjustRange() { Plot plot = getPlot(); if (plot == null) { return; // no plot, no data. if (r == null) { r = getDefaultAutoRange(); if (lower > 0.0 && (lowerMargin = getLowerMargin()) > 0.0) { lower = computeLogFloor(lower); if (upper > 0.0 && (upperMargin = getUpperMargin()) > 0.0) { upper = (this.autoRangeNextLogFlag) ? computeLogCeil(upper) : Math.ceil(upper); double minRange = getAutoRangeMinimumSize(); if (upper - lower < minRange) { upper = (upper + lower + minRange) / 2; setRange(new Range(lower, upper), false, false); setupSmallLogFlag(); //setup flag based on bounds values
/** * Overridden version that calls original and then sets up flag for log axis processing. * * @param range the range. */ @Override public void setRange(Range range) { super.setRange(range, true, true); setupSmallLogFlag(); // setup flag based on bounds values }
/** * Returns a power of 10, depending on if values between 0 and * 1 are being plotted. If negative values are not allowed and * the lower bound is between 0 and 10 then a normal power is * returned; otherwise the returned value is adjusted if the * given value is less than 1. * * @param val the value. * * @return 10<sup>val</sup>. * * @since 1.0.5 * @see #switchedLog10(double) */ public double switchedPow10(double val) { return this.smallLogFlag ? Math.pow(10.0, val) : adjustedPow10(val); }
private JFreeChart createChart(String title, XYDataset magDataset, String freqUnits, String magnitudeUnits) { XYItemRenderer renderer1 = new StandardXYItemRenderer(); NumberAxis rangeAxis1 = new NumberAxis("Magnitude " + magnitudeUnits); XYPlot subplot1 = new XYPlot(magDataset, new LogarithmicAxis("Frequency " + freqUnits), rangeAxis1, renderer1); subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); renderer1.setSeriesVisibleInLegend(0, false); return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, subplot1, true); } }
Plot plot = getPlot(); if (plot == null) { return; // no plot, no data. if (r == null) { r = getDefaultAutoRange(); if (lower > 0.0 && (lowerMargin = getLowerMargin()) > 0.0) { lower = computeLogFloor(lower); if (upper > 0.0 && (upperMargin = getUpperMargin()) > 0.0) { upper = (this.autoRangeNextLogFlag) ? computeLogCeil(upper) : Math.ceil(upper); double minRange = getAutoRangeMinimumSize(); if (upper - lower < minRange) { upper = (upper + lower + minRange) / 2; setRange(new Range(lower, upper), false, false); setupSmallLogFlag(); //setup flag based on bounds values
/** * Returns a power of 10, depending on if values between 0 and * 1 are being plotted. If negative values are not allowed and * the lower bound is between 0 and 10 then a normal power is * returned; otherwise the returned value is adjusted if the * given value is less than 1. * * @param val the value. * * @return 10<sup>val</sup>. * * @since 1.0.5 * @see #switchedLog10(double) */ public double switchedPow10(double val) { return this.smallLogFlag ? Math.pow(10.0, val) : adjustedPow10(val); }
private JFreeChart createChart(String title, XYDataset magDataset, String freqUnits, String magnitudeUnits) { XYItemRenderer renderer1 = new StandardXYItemRenderer(); NumberAxis rangeAxis1 = new NumberAxis("Magnitude " + magnitudeUnits); XYPlot subplot1 = new XYPlot(magDataset, new LogarithmicAxis("Frequency " + freqUnits), rangeAxis1, renderer1); subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); renderer1.setSeriesVisibleInLegend(0, false); return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, subplot1, true); } }
private JFreeChart createChart(final String title, final String categoryAxisLabel, final String valueAxisLabel, final XYSeriesCollection dataset) { JFreeChart c = ChartFactory.createXYLineChart(title, categoryAxisLabel, valueAxisLabel, dataset, PlotOrientation.VERTICAL, true, // legend? false, // tooltips? false // URLs? ); if (this.isLogarithmicAxis){ XYPlot p = (XYPlot) c.getPlot(); LogarithmicAxis axis_x = new LogarithmicAxis(this.xAxisLabel); LogarithmicAxis axis_y = new LogarithmicAxis(this.yAxisLabel); axis_x.setAllowNegativesFlag(false); axis_y.setAllowNegativesFlag(false); p.setDomainAxis(axis_x); p.setRangeAxis(axis_y); } return c; }
/** * Zooms in on the current range. * * @param lowerPercent the new lower bound. * @param upperPercent the new upper bound. */ public void zoomRange(double lowerPercent, double upperPercent) { double startLog = switchedLog10(getRange().getLowerBound()); double lengthLog = switchedLog10(getRange().getUpperBound()) - startLog; Range adjusted; if (isInverted()) { adjusted = new Range( switchedPow10( startLog + (lengthLog * (1 - upperPercent))), switchedPow10( startLog + (lengthLog * (1 - lowerPercent)))); } else { adjusted = new Range( switchedPow10(startLog + (lengthLog * lowerPercent)), switchedPow10(startLog + (lengthLog * upperPercent))); } setRange(adjusted); }
/** * Returns the log10 value, depending on if values between 0 and * 1 are being plotted. If negative values are not allowed and * the lower bound is between 0 and 10 then a normal log is * returned; otherwise the returned value is adjusted if the * given value is less than 10. * * @param val the value. * * @return log<sub>10</sub>(val). * * @see #switchedPow10(double) */ protected double switchedLog10(double val) { return this.smallLogFlag ? Math.log(val) / LOG10_VALUE : adjustedLog10(val); }
public void setLogScale(boolean range, boolean domain) { if( domain ) { NumberAxis axis = (NumberAxis)plot.getDomainAxis(); axis = new LogarithmicAxis(axis.getLabel()); plot.setDomainAxis(axis); } if( range ) { NumberAxis axis = (NumberAxis)plot.getRangeAxis(); axis = new LogarithmicAxis(axis.getLabel()); plot.setRangeAxis(axis); } }
private JFreeChart createChart(final String title, final String categoryAxisLabel, final String valueAxisLabel, final XYSeriesCollection dataset) { JFreeChart c = ChartFactory.createScatterPlot(title, categoryAxisLabel, valueAxisLabel, dataset, PlotOrientation.VERTICAL, true, // legend? false, // tooltips? false // URLs? ); if (this.isLogarithmicAxis) { XYPlot p = (XYPlot) c.getPlot(); LogarithmicAxis axis_x = new LogarithmicAxis(this.xAxisLabel); LogarithmicAxis axis_y = new LogarithmicAxis(this.yAxisLabel); axis_x.setAllowNegativesFlag(false); axis_y.setAllowNegativesFlag(false); p.setDomainAxis(axis_x); p.setRangeAxis(axis_y); } return c; }
private void setXAxis() { ValueAxis axis; switch (xAxisScaling) { case LOGARITHMIC: axis = new LogarithmicAxis(xLabel); break; case CONSTANT: default: axis = new NumberAxis(xLabel); break; } graph.getXYPlot().setDomainAxis(0, axis); }
LogarithmicAxis logAxisX = new LogarithmicAxis(resultUnitX); logAxisX.setAllowNegativesFlag(true); plot.setDomainAxis(logAxisX); LogarithmicAxis logAxis = new LogarithmicAxis(resultUnit); logAxis.setAllowNegativesFlag(true); plot.setRangeAxis(logAxis);
private void setYAxis() { ValueAxis axis; switch (yAxisScaling) { case LOGARITHMIC: axis = new LogarithmicAxis(xLabel); break; case CONSTANT: default: axis = new NumberAxis(xLabel); break; } graph.getXYPlot().setRangeAxis(0, axis); }