1

fI have done my data analysis in ipython using pandas and ggplot, but now i would like to move this to a gui and thought to use pyqt.

To create a figure in pyqt i would usually use matplotlib, something along these lines..

    import matplotlib.pyplot as plt
    figure = plt.figure()
    figure.add_subplot(111)
    ax.plot(data, '*-')

But I would like to use the integration between pandas and ggplot. But this does not work

    p = ggplot(mtcars, aes('mpg', 'qsec')) + geom_point(colour='steelblue')
    ax.plot(p)

How can I plot a python ggplot figure in a pyqt program?

4

2 回答 2

1

在上面的 p.draw() 将返回一个 matplotlib 图。您可以使用此图添加子图,然后将此轴传递给 pandas 绘图函数或直接使用 matplotlibs 绘图。目前无法将两个 ggplot 图(或任何现有图与新 ggplot 图)结合起来(参见 github.com/yhat/ggplot/issues/160 和 github.com/yhat/ggplot/issues/181)。

于 2014-02-21T22:24:04.540 回答
0

通过设置. _ PyQt5_pyplot

import matplotlib.pyplot as plt
plt.style.use('ggplot')
于 2019-12-20T10:12:32.133 回答