문제

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?

도움이 되었습니까?

해결책

In the above p.draw() will return a matplotlib figure. You could use this figure to add a subplot and then pass this axis to pandas plot function or use matplotlibs plotting directly. Combining two ggplot plots (or any existing plot with a new ggplot plot) is currently not possible (see github.com/yhat/ggplot/issues/160 and github.com/yhat/ggplot/issues/181).

다른 팁

I got a python ggplot figure working in a PyQt5 by setting the style of pyplot.

import matplotlib.pyplot as plt
plt.style.use('ggplot')
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top