Search code examples
jfreechart

Change axis label Color (JFreeChart)


Can anyone tell me how I can proceed to change the color of the axes' labels as circled below?

enter image description here


Solution

  • You can use setTickLabelPaint() and setLabelPaint() like this:

    Axis domain = plot.getDomainAxis();
    domain.setTickLabelPaint(Color.blue);
    domain.setLabelPaint(Color.blue);
    Axis range = plot.getRangeAxis();
    range.setTickLabelPaint(Color.red);
    range.setLabelPaint(Color.red);