Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MPAndroidChart: bottom x-axis and multiple y-axes

I have two questions about this awesome Android chart library:

1) I cannot find a way to put the x-axis at the bottom of the chart: is it possible?

2) is it possible to plot data against two (or more) y-axes on the same chart?

Thank you in advance

like image 303
user1737538 Avatar asked Oct 30 '14 12:10

user1737538


People also ask

How do you make a long x axis in a chart?

Create a tiled chart layout containing two tiles, and place an axes object across both tiles. In the final presentation, this axes object will appear in the background, behind two other axes objects. A section of its x -axis will be visible to give the appearance of one long x -axis.

How do I create a plot with different X-and y-axis limits?

Within one of the axes objects, move the x -axis to the top of the plot box, and move the y -axis to the right side of the plot box. For example, you can create two plots that have different x - and y -axis limits. First, create two sets of x - and y -coordinates. Create a tiled chart layout and an axes object. Then plot into the axes:

How do you plot two axes in Matplotlib?

Create a second axes object and plot the second set of data in black rather than red. Then, set properties on the second axes object to move the x -axis and y -axis, and to ensure that neither plot obscures the other. Create an axes object ax2 by calling the axes function and specifying t as the parent object.

How do you plot two X and y axis in Excel?

To plot two sets of data with separate x - and y -axes, create two separate axes objects in a tiled chart layout. Within one of the axes objects, move the x -axis to the top of the plot box, and move the y -axis to the right side of the plot box.


2 Answers

A bit has changed in the library. Now you will need to do as follows:

XAxis xAxis = chart.getXAxis();
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);

This will set the x-axis label at the bottom

like image 183
neaGaze Avatar answered Oct 19 '22 06:10

neaGaze


It is possible to put the XLabels to the bottom.

Call:

XLabels xl = chart.getXLabels();
xl.setPosition(XLabelPosition.BOTTOM);

Different y-axes descriptions (YLabels, with different data) are currently not supported.

like image 22
Philipp Jahoda Avatar answered Oct 19 '22 07:10

Philipp Jahoda