问题:Python中漂亮的图形和图表[关闭]

有哪些可用的库在Python应用程序中创建漂亮的图表和图形?

What are the available libraries for creating pretty charts and graphs in a Python application?


回答 0

我是支持CairoPlot的人,对此感到非常自豪。matplotlib当然很棒,但是我相信CairoPlot会更好看。因此,对于演示文稿和网站,这是一个很好的选择。

今天,我发布了1.1版。如果有兴趣,请在CairoPlot v1.1中进行检查

编辑:经过漫长而寒冷的冬天后,CairoPlot再次被开发。在GitHub上检查新版本。

I’m the one supporting CairoPlot and I’m very proud it came up here. Surely matplotlib is great, but I believe CairoPlot is better looking. So, for presentations and websites, it’s a very good choice.

Today I released version 1.1. If interested, check it out at CairoPlot v1.1

EDIT: After a long and cold winter, CairoPlot is being developed again. Check out the new version on GitHub.


回答 1

对于交互工作,Matplotlib是成熟的标准。它提供了OO风格的API以及Matlab风格的交互式API。

Chaco是Enthought的人们提供的更现代的绘图库。它使用Enthought的Kiva矢量绘图库,目前仅在OpenGL的情况下可用于Wx和Qt(Matplotlib具有Tk,Qt,Wx,Cocoa的后端,以及许多图像类型,如PDF,EPS,PNG等)。Chaco的主要优点是其相对于Matplotlib的速度以及与Enthought的用于交互应用程序的Traits API的集成。

For interactive work, Matplotlib is the mature standard. It provides an OO-style API as well as a Matlab-style interactive API.

Chaco is a more modern plotting library from the folks at Enthought. It uses Enthought’s Kiva vector drawing library and currently works only with Wx and Qt with OpenGL on the way (Matplotlib has backends for Tk, Qt, Wx, Cocoa, and many image types such as PDF, EPS, PNG, etc.). The main advantages of Chaco are its speed relative to Matplotlib and its integration with Enthought’s Traits API for interactive applications.


回答 2

您也可以使用使用Google Chart API的pygooglechart。这不是您始终想要使用的东西,但是如果您想要少量的简单,良好的图表并且始终在线,尤其是如果您仍在浏览器中显示,则这是一个不错的选择。

You can also use pygooglechart, which uses the Google Chart API. This isn’t something you’d always want to use, but if you want a small number of good, simple, charts, and are always online, and especially if you’re displaying in a browser anyway, it’s a good choice.


回答 3

您没有提到所需的输出格式,但是reportlab擅长以pdf和位图(例如png)格式创建图表。

这是png和pdf格式的条形图的简单示例:

from reportlab.graphics.shapes import Drawing
from reportlab.graphics.charts.barcharts import VerticalBarChart

d = Drawing(300, 200)

chart = VerticalBarChart()
chart.width = 260
chart.height = 160
chart.x = 20
chart.y = 20
chart.data = [[1,2], [3,4]]
chart.categoryAxis.categoryNames = ['foo', 'bar']
chart.valueAxis.valueMin = 0

d.add(chart)
d.save(fnRoot='test', formats=['png', 'pdf'])

替代文字http://i40.tinypic.com/2j677tl.jpg

注意:图像主机已将图像转换为jpg。

You didn’t mention what output format you need but reportlab is good at creating charts both in pdf and bitmap (e.g. png) format.

Here is a simple example of a barchart in png and pdf format:

from reportlab.graphics.shapes import Drawing
from reportlab.graphics.charts.barcharts import VerticalBarChart

d = Drawing(300, 200)

chart = VerticalBarChart()
chart.width = 260
chart.height = 160
chart.x = 20
chart.y = 20
chart.data = [[1,2], [3,4]]
chart.categoryAxis.categoryNames = ['foo', 'bar']
chart.valueAxis.valueMin = 0

d.add(chart)
d.save(fnRoot='test', formats=['png', 'pdf'])

alt text http://i40.tinypic.com/2j677tl.jpg

Note: the image has been converted to jpg by the image host.


回答 4


回答 5

我使用pychart,并认为它非常简单。

http://home.gna.org/pychart/

它全部是本机python,没有大量的依赖项。我确定matplotlib很可爱,但是我要下载和安装几天,我只想要一张measley条形图!

它似乎几年没有更新,但是嘿,它起作用了!

I used pychart and thought it was very straightforward.

http://home.gna.org/pychart/

It’s all native python and does not have a busload of dependencies. I’m sure matplotlib is lovely but I’d be downloading and installing for days and I just want one measley bar chart!

It doesn’t seem to have been updated in a few years but hey it works!


回答 6

您是否研究过适用于Python的ChartDirector

我不能谈论这个,但是我已经将ChartDirector用于PHP,这非常好。

Have you looked into ChartDirector for Python?

I can’t speak about this one, but I’ve used ChartDirector for PHP and it’s pretty good.


回答 7

NodeBox非常适合创建原始图形。

NodeBox is awesome for raw graphics creation.


回答 8

如果您想使用gnuplot进行绘图,则应考虑使用Gnuplot.py。它为gnuplot提供了一个面向对象的界面,还允许您将命令直接传递给gnuplot。不幸的是,它不再被积极开发。

If you like to use gnuplot for plotting, you should consider Gnuplot.py. It provides an object-oriented interface to gnuplot, and also allows you to pass commands directly to gnuplot. Unfortunately, it is no longer being actively developed.


回答 9

查科enthought是另一种选择


回答 10

您还应该考虑使用PyCha http://www.lorenzogil.com/projects/pycha/


回答 11

我是PyOFC2的粉丝: http

它只是一个软件包,可轻松生成非常漂亮的Open Flash Charts 2所需的JSON数据。在上面的链接上查看示例。

I am a fan on PyOFC2 : http://btbytes.github.com/pyofc2/

It just just a package that makes it easy to generate the JSON data needed for Open Flash Charts 2, which are very beautiful. Check out the examples on the link above.


回答 12

请查看嵌入WHIFF的Open Flash Chart http://aaron.oirt.rutgers.edu/myapp/docs/W1100_1600.openFlashCharts 和嵌入WHIFF的amCharts http://aaron.oirt.rutgers.edu/myapp/ amcharts / doc。谢谢。

Please look at the Open Flash Chart embedding for WHIFF http://aaron.oirt.rutgers.edu/myapp/docs/W1100_1600.openFlashCharts and the amCharts embedding for WHIFF too http://aaron.oirt.rutgers.edu/myapp/amcharts/doc. Thanks.


回答 13

您也可以考虑使用Google图表

从技术上讲,这不是python API,但是您可以从python中使用它,它的编码速度相当快,并且结果看起来不错。如果您碰巧正在在线使用地块,那么这将是一个更好的解决方案。

You could also consider google charts.

Not technically a python API, but you can use it from python, it’s reasonably fast to code for, and the results tend to look nice. If you happen to be using your plots online, then this would be an even better solution.


回答 14

PLplot是用于创建科学图的跨平台软件包。它们不是很漂亮(引人注目),但看起来足够好。看一些例子(源代码和图片)。

PLplot核心库可用于创建标准的xy图,半对数图,对数对数图,轮廓图,3D表面图,网格图,条形图和饼图。它可以在Windows(2000,XP和Vista),Linux,Mac OS X和其他Unices上运行。

PLplot is a cross-platform software package for creating scientific plots. They aren’t very pretty (eye catching), but they look good enough. Have a look at some examples (both source code and pictures).

The PLplot core library can be used to create standard x-y plots, semi-log plots, log-log plots, contour plots, 3D surface plots, mesh plots, bar charts and pie charts. It runs on Windows (2000, XP and Vista), Linux, Mac OS X, and other Unices.


声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。