作为以前的R用户,我曾经通过ggplotly()函数将ggplot和plot_ly库广泛地组合在一起,以显示数据。
在新加入的Python中,我看到ggplot库是可用的,但是找不到任何简单的与plotly相结合的图形反应式显示。
我想要找的东西是:
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)其中最后一行将启动一个经典的绘图动态查看器,具有鼠标图形交互、曲线选择等所有强大的功能。
感谢您的帮助:),
纪劳姆
发布于 2020-04-30 06:26:13
这个开放的plotnine issue描述了一个类似的增强请求。
目前,mpl_to_plotly函数有时似乎可以工作(对于某些geom?),但并不一致。下面的代码,看起来工作正常。
from plotnine import *
from plotly.tools import mpl_to_plotly as ggplotly
import numpy as np
import pandas as pd
a = pd.DataFrame({'grid': np.arange(-4, 4),
'test_data': np.random.randint(0, 10,8)})
p2 = ggplot(a, aes(x = 'grid', y = 'test_data')) + geom_point()
ggplotly(p2.draw())发布于 2019-12-14 03:54:19
如果你所寻找的只是一个交互式的界面,那么你不需要在python中使用ggplotly。ggplot (或者至少是plotnine,这是我正在使用的实现)使用了matplotlib,它已经是交互式的,不像R ggplot2包需要在顶部使用plotly。
https://stackoverflow.com/questions/50587634
复制相似问题