使用 ReportLab 在图表上拟合曲线
我正在使用开源 ReportLab 准备一组报告。报告包含许多图表。到目前为止一切都运转良好。
我被要求制作一个(工作)条形图,显示两个系列的数据,并为每个系列叠加一条拟合曲线。
我可以看到如何通过在同一个 ReportLab 绘图中创建折线图和条形图来在条形图上叠加分段线。但是,我在 ReportLab 中找不到任何拟合曲线的参考。
有没有人对在 ReportLab 中绘制一系列数据的拟合曲线有任何见解,或者如果失败的话,有关于如何完成此任务的建议(我认为图表需要在 matplotlib 中生成)?
I'm preparing a set of reports using open source 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. I can't find any reference for fitted curves in ReportLab, however.
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)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议使用 MatPlotLib。这正是它设计要处理的事情,它比尝试单独在 ReportLab 中拼凑一些东西要容易得多,特别是因为您必须自己完成所有行的计算并找出以下细节:如何将其绘制在正确的位置。 MatPlotLib 与 ReportLab 轻松集成;我已经多次使用该组合并取得了很好的效果。
I would recommend using 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. MatPlotLib integrates easily with ReportLab; I've used the combination several times with great results.