如何用ChartDirector绘制3D散点图

 我来答
福喜900
2014-12-01 · TA获得超过6.1万个赞
知道大有可为答主
回答量:1.1万
采纳率:0%
帮助的人:1亿
展开全部
主要有以下几个步骤:
1、用ThreeDScatterChart.ThreeDScatterChart创建一个ThreeDScatterChart对象
2、用ThreeDChart.setPlotRegion指定绘图区域的位置和大小
3、用ThreeDScatterChart.addScatterGroup向图表添加一组散点。在本例中,标记颜色设置为SameAsMainColor,颜色会根据Z坐标的颜色轴进行变化,颜色轴的访问可以用ThreeDChart.colorAxis。
4、用ThreeDChart.setColorAxis设置颜色轴的位置
5、分别用BaseChart.addTitle 和 Axis.setTitle添加图表和轴标题
6、最后用BaseChart.makeChart生成图表
下面是ChartDirector生成三维散点图的部分代码:
123456789101112131415161718192021222324252627282930313233343536373839404142 #include "chartdir.h" int main(int argc, char *argv[]){ // The XYZ data for the 3D scatter chart as 3 random data series RanSeries *r = newRanSeries(0); DoubleArray xData = r->getSeries(100, 100, -10, 10); DoubleArray yData = r->getSeries(100, 0, 0, 20); DoubleArray zData = r->getSeries(100, 100, -10, 10); // Create a ThreeDScatterChart object of size 720 x 600 pixels ThreeDScatterChart *c = newThreeDScatterChart(720, 600); // Add a title to the chart using 20 points Times New Roman Italic font c->addTitle("3D Scatter Chart (1) ","timesi.ttf", 20); // Set the center of the plot region at (350, 280), and set width x depth x // height to 360 x 360 x 270 pixels c->setPlotRegion(350, 280, 360, 360, 270); // Add a scatter group to the chart using 11 pixels glass sphere symbols, in // which the color depends on the z value of the symbol c->addScatterGroup(xData, yData, zData, "", Chart::GlassSphere2Shape, 11, Chart::SameAsMainColor); // Add a color axis (the legend) in which the left center is anchored at (645, // 270). Set the length to 200 pixels and the labels on the right side. c->setColorAxis(645, 270, Chart::Left, 200, Chart::Right); // Set the x, y and z axis titles using 10 points Arial Bold font c->xAxis()->setTitle("X-Axis Place Holder", "arialbd.ttf", 10); c->yAxis()->setTitle("Y-Axis Place Holder", "arialbd.ttf", 10); c->zAxis()->setTitle("Z-Axis Place Holder","arialbd.ttf", 10); // Output the chart c->makeChart("threedscatter.png"); //free up resources deleter; delete c; return 0;}
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式