【问题标题】:Generate interactive plot using mne package in google colab在 google colab 中使用 mne 包生成交互式绘图
【发布时间】:2021-02-03 21:56:21
【问题描述】:

我正在尝试使用 mne 包生成 EEG 数据的交互式图。但它不适用于 Google Colab。它给了我 2 个完全相同的静态图。知道如何解决吗?

【问题讨论】:

    标签: python plot interactive google-colaboratory


    【解决方案1】:

    解决方案

    据我所知,Google Colab 目前不允许使用 %matplotlib notebook 作为后端。通常,在制作matplotlib 绘图时,使用%matplotlib notebook 进行交互。您正在使用的包似乎使用matplotlib 进行可视化。所以,现在,你运气不好!

    您将使用其他库:altairplotlybokeh 等在 Colab 上实现交互。

    查看此 colab 笔记本:Charting in Colaboratory。在 colab-notebook 中有各种可视化包的详细示例,可帮助您入门。

    用于 Colab 上的交互式绘图的 Altair 代码示例

    Altair 是一个用于在 Python 中创建交互式可视化的声明式可视化库,在 Colab 中默认安装并启用。

    例如,这是一个交互式散点图:

    import altair as alt
    from vega_datasets import data
    cars = data.cars()
    
    alt.Chart(cars).mark_point().encode(
        x='Horsepower',
        y='Miles_per_Gallon',
        color='Origin',
    ).interactive()
    

    参考文献

    我建议您也看看以下资源。

    1. Charting in Colaboratory - colab-notebook-example

    2. Interactive matplotlib figures in Google Colab

    【讨论】:

      猜你喜欢
      • 2019-08-14
      • 2021-01-18
      • 1970-01-01
      • 2021-03-25
      • 1970-01-01
      • 2019-03-22
      • 2022-06-13
      • 2020-10-05
      • 2021-04-03
      相关资源
      最近更新 更多