I think that you mean that you want to hide the tick labels for the Y axis, but still want to see the label for the axis itself. Am I correct?
You can do that with:
axis1.setTickLabelsVisible(false);
Okay, if you want to:
- hide the label in the chart
- but still have it in the
NumberAxis
Then there is one solution, that isn't perfect either, that you could use. If you set the "attributed label" (a label with extra font markup attributes), it will draw the attributed label instead. You can set it to a single space (a zero-length string doesn't work - the font rendering code doesn't allow that).
rangeAxis.setAttributedLabel(" ");
At least axis1.getLabel()
will still return your old label, but that's the only benefit of this that I can see.
Otherwise, you can subclass NumberAxis
and override the method drawLabel
in the subclass to do nothing:
protected AxisState drawLabel(String label, Graphics2D g2,
Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge,
AxisState state) {
return state;
}