简体   繁体   English

使用ReportLab在图表上拟合曲线

[英]Fitted curve on chart using ReportLab

I'm preparing a set of reports using open source ReportLab. 我正在使用开源ReportLab准备一组报告。 The reports contain a number of charts. 报告中包含许多图表。 Everything works well so far. 到目前为止一切正常。

I've been asked to take a (working) bar chart that shows two series of data and overlay a fitted curve for each series. 我被要求制作一个(工作的)条形图,该图显示两个系列的数据并覆盖每个系列的拟合曲线。

I can see how I could overlay a segmented line on the bar graph by creating both a line chart and bar chart in the same ReportLab drawing. 我可以看到如何通过在同一ReportLab绘图中创建折线图和条形图来在条形图上覆盖分段线。 I can't find any reference for fitted curves in ReportLab, however. 但是,我在ReportLab中找不到拟合曲线的任何参考。

Does anyone have any insight into plotting a fitted curve to a series of data in ReportLab or, failing that, a suggestion about how to accomplish this task (I'm thinking that chart would need to be produced in matplotlib instead)? 是否有人对将拟合曲线绘制到ReportLab中的一系列数据有任何见解,否则,是否有关于如何完成此任务的建议(我认为应该在matplotlib中生成图表)?

I would recommend using MatPlotLib. 我建议使用MatPlotLib。 This is exactly the sort of thing it's designed to handle and it will be much easier than trying to piece together something in ReportLab alone, especially since you'll have to do all the calculation of the line on your own and figure out the details of how to draw it in just the right place. 这恰好是它设计要处理的事情,这比尝试单独在ReportLab中拼凑起来要容易得多,尤其是因为您必须自己进行所有的行计算并弄清楚其中的细节。如何在正确的位置绘制它。 MatPlotLib integrates easily with ReportLab; MatPlotLib可轻松与ReportLab集成; I've used the combination several times with great results. 我已经多次使用组合,效果很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM