Python ggplot和ggplotly [英] Python ggplot and ggplotly

查看:89
本文介绍了Python ggplot和ggplotly的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以前的R用户,我曾经通过ggplotly()函数广泛地组合了ggplot和plot_ly库来显示数据.

Former R user, I used to combine extensively ggplot and plot_ly libraries via the ggplotly() function to display data.

Python刚出现,我发现ggplot库可用,但是在与plotly的简单组合中无法找到任何用于图形反应显示的内容.

Newly arrived in Python, I see that the ggplot library is available, but cant find anything on a simple combination with plotly for graphical reactive displays.

我想要的是类似的东西:

What I would look for is something like :

from ggplot import*
import numpy as np
import pandas as pd

a = pd.DataFrame({'grid': np.arange(-4, 4),
                 'test_data': np.random.random_integers(0, 10,8)})
p2 = ggplot(a, aes(x = 'grid', y = 'test_data'))+geom_line()
p2
ggplotly(p2)

最后一行将在其中启动经典的绘图动态查看器,该查看器具有鼠标图形交互,曲线选择等所有出色的功能...

Where the last line would launch a classic plotly dynamic viewer with all the great functionalities of mouse graphical interactions, curves selections and so on...

感谢您的帮助:),

纪尧姆

推荐答案

如果您想要的只是一个交互式界面,则不需要在python中进行ggplotly. ggplot(或至少是我正在使用的实现为plotnine)使用已经具有交互性的matplotlib,这与R ggplot2程序包要求在顶部放置图是不同的.

You don't need ggplotly in python if all you are seeking is an interactive interface. ggplot (or at least plotnine, which is the implementation that I am using) uses matplotlib which is already interactive, unlike the R ggplot2 package that requires plotly on top.

这篇关于Python ggplot和ggplotly的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆