我已经在我的应用程序中实现了 AndroidPlot,它工作正常,除了 X 轴标签,它们从 0 到 10。我想显示 1 到 11。此外,不会出现 Y 轴上的标签。
我正在使用的代码:
import java.text.DecimalFormat;
import java.util.Arrays;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import com.androidplot.series.XYSeries;
import com.androidplot.xy.LineAndPointFormatter;
import com.androidplot.xy.SimpleXYSeries;
import com.androidplot.xy.XYPlot;
import com.androidplot.xy.XYStepMode;
public class Scatter extends Activity {
private XYPlot mySimpleXYPlot;
//declare new arrays
float[] one;
float[] two;
float[] three;
Number[] series1Numbers;
Number[] series2Numbers;
Number[] series3Numbers;
String chainringCount;
/** Called when the activity is first created. */
@SuppressWarnings("deprecation")
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.scatter);
Bundle bundle = this.getIntent().getExtras();
one = bundle.getFloatArray("one");
two = bundle.getFloatArray("two");
three = bundle.getFloatArray("three");
chainringCount=bundle.getString("CC");
if (Integer.parseInt(chainringCount)==1){
series1Numbers = new Number[one.length];
for (int a=0; a<one.length; a++){
series1Numbers[a]=one[a];
}
mySimpleXYPlot = (XYPlot) findViewById(R.id.mySimpleXYPlot);
mySimpleXYPlot.setDomainStep(XYStepMode.SUBDIVIDE,11);
mySimpleXYPlot.setDomainStep(XYStepMode.INCREMENT_BY_VAL,1);
mySimpleXYPlot.setDomainValueFormat(new DecimalFormat("#"));
mySimpleXYPlot.setTicksPerRangeLabel(13);
mySimpleXYPlot.disableAllMarkup();
mySimpleXYPlot.getBackgroundPaint().setAlpha(0);
mySimpleXYPlot.getGraphWidget().getBackgroundPaint().setAlpha(0);
mySimpleXYPlot.getGraphWidget().getGridBackgroundPaint().setAlpha(0);
mySimpleXYPlot.setDomainLabel(getString(R.string.domainName));
mySimpleXYPlot.setRangeLabel(getString(R.string.rangeName));
XYSeries series1 = new SimpleXYSeries(Arrays.asList(series1Numbers), SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "#1");
LineAndPointFormatter series1Format = new LineAndPointFormatter(Color.rgb(0, 200, 0), Color.rgb(0, 100, 0),null); // fill color (none)
mySimpleXYPlot.addSeries(series1, series1Format);
}...