1

I have an issue with my graph, when I plot my data, the Range Origin Label is not showing. That is, the first label on the Y-axis is not displayed. I have set my Range step to be:

plotView.setRangeStep(XYStepMode.SUBDIVIDE, 10);

However, it only shows 9 labels.

How do I make sure that the range origin label is set?

I have already tried the following:

widget.getRangeLabelPaint().setColor(Color.BLACK);
widget.getRangeOriginLinePaint().setColor(Color.BLACK);

Any help is greatly appreciated.

1 Answer 1

2

You have to use

plotView.getGraphWidget().getRangeOriginLabelPaint().setColor(Color.BLACK);.

plotView.getGraphWidget().getRangeOriginLinePaint().setColor(Color.BLUE);

and

plotView.getGraphWidget().getRangeLabelPaint().setColor(Color.RED);

are doing this:

enter image description here

Notice the red range labels and the blue origin line.

As for plotView.setRangeStep(XYStepMode.SUBDIVIDE, 10);, it's dividing your plotview in 10 parts, including the origin.

I'm using plotView.setRangeStepValue(10);. Does the same thing, but with simpler syntax.

UPDATE:

To add a label under the origin labels you have to add first a border style (SQUARE or ROUND):

plotView.setBorderStyle(Plot.BorderStyle.SQUARE, null, null);

Then:

plotView.setDomainLabel("Samples");
plotView.getDomainLabelWidget().pack();
plotView.position(
            plotView.getDomainLabelWidget(),                     
                0,                                    
                XLayoutStyle.RELATIVE_TO_CENTER,       
                0,                                     
                YLayoutStyle.ABSOLUTE_FROM_BOTTOM,     
                AnchorPosition.BOTTOM_MIDDLE);
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks a lot! I cannot believe I missed that, I thought I had tried everything ;). Now, do you know how I can easily write something horizontally centered below the domain labels?
@SimonLanghoff I've updated my answer with what you've asked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.