Example usage for org.jfree.chart.axis CategoryAxis setTickLabelFont

List of usage examples for org.jfree.chart.axis CategoryAxis setTickLabelFont

Introduction

In this page you can find the example usage for org.jfree.chart.axis CategoryAxis setTickLabelFont.

Prototype

public void setTickLabelFont(Font font) 

Source Link

Document

Sets the font for the tick labels and sends an AxisChangeEvent to all registered listeners.

Usage

From source file:weka.core.ChartUtils.java

/**
 * Render a histogram chart from summary data (i.e. a list of bin labels and
 * corresponding frequencies) to a buffered image
 * //from  www .  j  av  a2 s  .c om
 * @param width the width of the resulting image
 * @param height the height of the resulting image
 * @param bins the list of bin labels
 * @param freqs the corresponding bin frequencies
 * @param additionalArgs optional arguments to the renderer (may be null)
 * @return a histogram as a buffered image
 * @throws Exception if a problem occurs
 */
public static BufferedImage renderHistogramFromSummaryData(int width, int height, List<String> bins,
        List<Double> freqs, List<String> additionalArgs) throws Exception {

    JFreeChart chart = getHistogramFromSummaryDataChart(bins, freqs, additionalArgs);
    CategoryAxis axis = chart.getCategoryPlot().getDomainAxis();
    axis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
    Font newFont = new Font("SansSerif", Font.PLAIN, 11);
    axis.setTickLabelFont(newFont);
    BufferedImage image = chart.createBufferedImage(width, height);
    return image;
}

From source file:com.rapidminer.gui.new_plotter.engine.jfreechart.ChartAxisFactory.java

public static CategoryAxis createCategoryDomainAxis(PlotConfiguration plotConfiguration) {
    CategoryAxis domainAxis = new CategoryAxis(null);
    String label = plotConfiguration.getDomainConfigManager().getLabel();
    if (label == null) {
        label = I18N.getGUILabel("plotter.unnamed_value_label");
    }/*from  w  ww  . ja  v a  2 s  . c o  m*/
    domainAxis.setLabel(label);

    Font axesFont = plotConfiguration.getAxesFont();
    if (axesFont != null) {
        domainAxis.setLabelFont(axesFont);
        domainAxis.setTickLabelFont(axesFont);
    }

    // rotate labels
    if (plotConfiguration.getOrientation() != PlotOrientation.HORIZONTAL) {
        domainAxis.setCategoryLabelPositions(
                CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 2.0d));
    }

    formatAxis(plotConfiguration, domainAxis);
    return domainAxis;
}

From source file:org.amanzi.awe.charts.builder.StackedChartBuilder.java

@Override
public JFreeChart createChart() throws ModelException {
    CategoryDatasetContainer dataset = new CategoryDatasetContainer(getModel());
    dataset.computeDatasets();/*  w ww.  java  2 s . c  o  m*/
    JFreeChart chart = ChartFactory.createStackedBarChart(getModel().getName(), // chart
            // title
            getModel().getDomainAxisName(), getModel().getMainRangeAxis().getName(),
            dataset.getDataset(getModel().getMainRangeAxis()), getModel().getPlotOrientation(), true, true,
            false);
    CategoryPlot plot = ((CategoryPlot) chart.getPlot());
    plot.setRenderer(new StackedBarRenderer3D());
    CategoryAxis axis = plot.getDomainAxis();
    axis.setTickLabelFont(getDefaulTickLabelFont());
    axis.setLabelFont(getDefaultAxisFont());
    chart.addSubtitle(getSubTitle(Messages.clickItemToDrillDown));
    return chart;
}

From source file:playground.anhorni.PLOC.analysis.RunsEnsembleBoxPlot.java

public JFreeChart createChart() {
    String title = chartTitle;/*from   w  w w .j a va2  s.co  m*/

    final CategoryAxis xAxis = new CategoryAxis("Hour");
    xAxis.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 10));
    xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);

    final NumberAxis yAxis = new NumberAxis("AverageDays_Expenditures");
    yAxis.setAutoRangeIncludesZero(true);

    final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    renderer.setFillBox(false);
    renderer.setSeriesPaint(0, Color.blue);
    CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);

    this.chart_ = new JFreeChart(title, new Font("SansSerif", Font.BOLD, 14), plot, false);
    return this.chart_;
}

From source file:playground.anhorni.PLOC.analysis.MultipleEnsemblesBoxPlot.java

public JFreeChart createChart() {
    String title = chartTitle;/*from  ww  w.  j av a 2  s  . com*/

    final CategoryAxis xAxis = new CategoryAxis("Runs ensemble size");
    xAxis.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 10));
    xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);

    final NumberAxis yAxis = new NumberAxis("AvgDaysRuns_OfEnsembleAverageOfTotalExpenditures");
    yAxis.setAutoRangeIncludesZero(true);

    final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    renderer.setFillBox(false);
    renderer.setSeriesPaint(0, Color.blue);
    CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);

    this.chart_ = new JFreeChart(title, new Font("SansSerif", Font.BOLD, 14), plot, false);
    return this.chart_;
}

From source file:playground.anhorni.surprice.analysis.SupriceBoxPlot.java

public JFreeChart createChart() {
    String title = chartTitle;//from w w w  .j a va  2 s. c  om

    final CategoryAxis xAxis = new CategoryAxis(this.xAxisName);
    xAxis.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 10));
    xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);

    final NumberAxis yAxis = new NumberAxis(this.yAxisName);
    yAxis.setAutoRangeIncludesZero(true);

    if (Math.abs(yrangeLower - yrangeUpper) > Double.MIN_VALUE) {
        yAxis.setRange(yrangeLower, yrangeUpper);
    }

    final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    renderer.setFillBox(false);
    renderer.setSeriesPaint(0, Color.blue);
    CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);

    this.chart_ = new JFreeChart(title, new Font("SansSerif", Font.BOLD, 14), plot, false);
    return this.chart_;
}

From source file:playground.anhorni.counts.StdDevBoxPlot.java

public JFreeChart createChart() {
    DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();

    ArrayList<Double>[] lists = this.createArrayLists();

    // add the collected values to the graph / dataset
    for (int i = 0; i < 24; i++) {
        dataset.add(lists[i], "hour", Integer.toString(i + 1));
    }/*w w  w  . j a va 2 s  .c o m*/
    final CategoryAxis xAxis = new CategoryAxis(xlabel);
    xAxis.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 10));
    //xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);

    final NumberAxis yAxis = new NumberAxis(ylabel);
    yAxis.setAutoRangeIncludesZero(true);

    final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    renderer.setFillBox(false);
    renderer.setSeriesPaint(0, Color.blue);
    CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);

    this.chart_ = new JFreeChart(chartTitle, new Font("SansSerif", Font.BOLD, 14), plot, false);
    return this.chart_;
}

From source file:playground.artemc.socialCost.MeanTravelTimeWriter.java

/**
 * @return a graphic showing the number of agents in the evacuated area
 *//* www  . j  av a2  s . c  om*/
private JFreeChart getGraphic(String modeName, double data[]) {

    final XYSeriesCollection xyData = new XYSeriesCollection();
    final XYSeries dataSerie = new XYSeries("mean trip travel time", false, true);

    for (int i = 0; i < data.length; i++) {
        dataSerie.add(i, data[i]);
    }

    xyData.addSeries(dataSerie);

    //      final JFreeChart chart = ChartFactory.createXYStepChart(
    final JFreeChart chart = ChartFactory.createXYLineChart("mean travel time, " + modeName, "iteration",
            "travel time", xyData, PlotOrientation.VERTICAL, true, // legend
            false, // tooltips
            false // urls
    );

    XYPlot plot = chart.getXYPlot();

    final CategoryAxis axis1 = new CategoryAxis("hour");
    axis1.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 7));
    plot.setDomainAxis(new NumberAxis("time"));
    return chart;
}

From source file:playground.artemc.socialCost.MeanTravelTimeWriter.java

/**
 * @return a graphic showing the number of agents in the evacuated area
 *///from w  w w .j  av a 2  s . c  om
private JFreeChart getGraphic(String[] modeNames, double data[][]) {

    final XYSeriesCollection xyData = new XYSeriesCollection();

    for (int j = 0; j < modeNames.length; j++) {
        String modeName = modeNames[j];
        double[] d = data[j];

        XYSeries dataSerie = new XYSeries(modeName, false, true);

        for (int i = 0; i < d.length; i++) {
            dataSerie.add(i, d[i]);
        }

        xyData.addSeries(dataSerie);
    }

    //      final JFreeChart chart = ChartFactory.createXYStepChart(
    final JFreeChart chart = ChartFactory.createXYLineChart("mean trip travel time, all transport modes modes",
            "iteration", "travel time", xyData, PlotOrientation.VERTICAL, true, // legend
            false, // tooltips
            false // urls
    );

    XYPlot plot = chart.getXYPlot();

    final CategoryAxis axis1 = new CategoryAxis("hour");
    axis1.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 7));
    plot.setDomainAxis(new NumberAxis("time"));
    return chart;
}

From source file:org.matsim.counts.algorithms.graphs.BoxPlotErrorGraph.java

@SuppressWarnings("unchecked")
@Override// w  ww. ja v a  2s. co m
public JFreeChart createChart(final int nbr) {

    DefaultBoxAndWhiskerCategoryDataset dataset0 = new DefaultBoxAndWhiskerCategoryDataset();
    DefaultBoxAndWhiskerCategoryDataset dataset1 = new DefaultBoxAndWhiskerCategoryDataset();

    final ArrayList<Double>[] listRel = new ArrayList[24];
    final ArrayList<Double>[] listAbs = new ArrayList[24];

    // init
    for (int i = 0; i < 24; i++) {
        listRel[i] = new ArrayList<Double>();
        listAbs[i] = new ArrayList<Double>();
    }

    // add the values of all counting stations to each hour
    for (CountSimComparison cc : this.ccl_) {
        int hour = cc.getHour() - 1;
        listRel[hour].add(cc.calculateRelativeError());
        listAbs[hour].add(cc.getSimulationValue() - cc.getCountValue());
    }

    // add the collected values to the graph / dataset
    for (int i = 0; i < 24; i++) {
        dataset0.add(listRel[i], "Rel Error", Integer.toString(i + 1));
        dataset1.add(listAbs[i], "Abs Error", Integer.toString(i + 1));
    }

    String title = "Iteration: " + this.iteration_;

    final CombinedDomainCategoryPlot plot = new CombinedDomainCategoryPlot();

    final CategoryAxis xAxis = new CategoryAxis("Hour");
    final NumberAxis yAxis0 = new NumberAxis("Signed Rel. Error [%]");
    final NumberAxis yAxis1 = new NumberAxis("Signed Abs. Error [veh]");
    yAxis0.setAutoRangeIncludesZero(false);
    yAxis1.setAutoRangeIncludesZero(false);

    final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    renderer.setFillBox(false);
    renderer.setSeriesPaint(0, Color.blue);
    renderer.setSeriesToolTipGenerator(0, new BoxAndWhiskerToolTipGenerator());

    CategoryPlot subplot0 = new CategoryPlot(dataset0, xAxis, yAxis0, renderer);
    CategoryPlot subplot1 = new CategoryPlot(dataset1, xAxis, yAxis1, renderer);

    plot.add(subplot0);
    plot.add(subplot1);

    final CategoryAxis axis1 = new CategoryAxis("hour");
    axis1.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 7));
    axis1.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
    plot.setDomainAxis(axis1);

    this.chart_ = new JFreeChart(title, new Font("SansSerif", Font.BOLD, 14), plot, false);
    return this.chart_;
}