到目前为止,我正在使用AndroidPlot创建一个波特图,到目前为止,图表看起来还不错。下面是图表:
我现在正在尝试扩展图形区域并删除它周围的所有不需要的空间。我试过了: How do I remove all space around a chart in AndroidPlot?
http://androidplot.com/docs/borders-margins-and-padding/
他们似乎没有做到这一点。我可能会错过一两块拼图。下面是代码片段:
/**
* AndroidPlot
*/
// Change Magnitude Plot Display
XYPlot mChart = (XYPlot) mView.findViewById(R.id.plot_magnitude);
Widget magGraphWidget = mChart.getGraphWidget();
// get a handle to the layout manager:
LayoutManager magLayoutManager = mChart.getLayoutManager();
magLayoutManager.remove(mChart.getLegendWidget());
magLayoutManager.remove(mChart.getDomainLabelWidget());
XYSeries magnitudeSeries = new SimpleXYSeries(Arrays.asList(logFreqs), Arrays.asList(magImp), "Magnitude");
// create formatters to use for drawing a series using LineAndPointRenderer
// and configure them from xml:
LineAndPointFormatter magnitudeSeriesFormat = new LineAndPointFormatter(
Color.rgb(0, 0, 0), Color.rgb(50, 180, 50), null, null
);
// just for fun, add some smoothing to the lines:
// see: http://androidplot.com/smooth-curves-and-androidplot/
magnitudeSeriesFormat.setInterpolationParams(new CatmullRomInterpolator.Params(10, CatmullRomInterpolator.Type.Centripetal));
// add a new series' to the xyplot:
mChart.addSeries(magnitudeSeries, magnitudeSeriesFormat);
// rotate domain labels 45 degrees to make them more compact horizontally:
mChart.getGraphWidget().setDomainLabelOrientation(-45);
// FILL mode with values of 0 means fill 100% of container:
mChart.setPlotMargins(0, 0, 0, 0);
mChart.setPlotPadding(0, 0, 0, 0);
mChart.getGraphWidget().setMarginTop(2);
mChart.getGraphWidget().setMarginRight(2);
mChart.getGraphWidget().setMarginLeft(2);
mChart.getGraphWidget().setMarginBottom(2);
mChart.setBorderPaint(null);
mChart.setMarkupEnabled(true);
magGraphWidget.setBackgroundPaint(null);
magGraphWidget.setSize(new Size(0, SizeLayoutType.FILL, 0, SizeLayoutType.FILL));
magGraphWidget.position(-0.5f, XLayoutStyle.ABSOLUTE_FROM_LEFT, -0.5f, YLayoutStyle.ABSOLUTE_FROM_TOP); //, AnchorPosition.CENTER);
mChart.redraw(); //update chart
这是XML:
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.androidplot.xy.XYPlot
android:id="@+id/plot_magnitude"
style="@style/APDefacto.Light"
android:layout_width="fill_parent"
android:layout_height="200dp"
ap:label="Bode Plot"
ap:rangeLabel="Magnitude (ohm)"
ap:labelTextSize="@dimen/title_font_size"
ap:paddingBottom="0dp"
android:paddingEnd="0dp"
ap:paddingLeft="0dp"
ap:paddingRight="0dp"
ap:paddingTop="0dp"
android:paddingStart="0dp"
android:padding="0dp"
android:layout_margin="0dp"
android:layout_marginBottom="0dp"
android:layout_marginEnd="0dp"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
android:layout_marginStart="0dp"
android:layout_marginTop="0dp"
/>
</FrameLayout>
如果有人可以帮助我。提前谢谢。
答案 0 :(得分:1)
按照图片,看起来它是您尝试删除的图形边距。尝试将此添加到您的情节XML:
ap:graphMarginLeft="0dp"
ap:graphMarginRight="0dp"
ap:graphMarginTop="0dp"
ap:graphMarginBottom="0dp"