4

Currently the domain label is positioned below the Y axis labels. Is there a way to set the domain label to appear in the middle of the X axis?

Using the below image as an example I want the domain label (Time secs) to appear where the legend (Thread #1) appears. (legend will not be visible).

chart example
(source: androidplot.com)

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Mark
  • 183
  • 4
  • 12

3 Answers3

3

To center the domain label I used the below.

plot.getDomainLabelWidget().position(0, XLayoutStyle.ABSOLUTE_FROM_CENTER, 0, YLayoutStyle.RELATIVE_TO_BOTTOM,  AnchorPosition.BOTTOM_MIDDLE);
Mark
  • 183
  • 4
  • 12
1

Take a look at the "LayoutManager" section of the "Plot Composition" doc. It gives a pretty good summary of how to position the visual elements (referenced as widgets in the doc) of a plot. In your case you'll be invoking plot.getDomainTitle().position(...).

Nick
  • 8,181
  • 4
  • 38
  • 63
  • Im not seeing this section in the documentation. My plot also does not have the function getDomainLabelWidget(). Can you point me to an updated place in the documentation where I can find this? – MadProgrammer Mar 03 '17 at 00:41
0

This worked for me with v1.5.4:

plot.getDomainTitle().getPositionMetrics().setXPositionMetric(new HorizontalPosition(0, HorizontalPositioning.ABSOLUTE_FROM_CENTER));

It sets the horizontal position to the center without modifying the vertical position.

It may also be useful to set the text alignment to CENTER:

plot.getDomainTitle().getLabelPaint().setTextAlign(Paint.Align.CENTER);