0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

spyder-notebookでplotlyを使う

Last updated at Posted at 2025-01-14

結論

Spyder側で
設定→アプリケーション→詳細設定→レンダリングエンジン→Desktop

に設定し、

import plotly.io as pio
pio.renderers.default = 'iframe'

を実行することでうまく表示できました。以下サンプルです。

import plotly.graph_objects as go
import plotly.io as pio
import numpy as np

pio.renderers.default = 'png'

fig = go.Figure(data=[go.Scatter3d(
    x=np.random.rand(20),
    y=np.random.rand(20),
    z=np.random.rand(20),
    mode='markers',     
    marker={'size':5, 'color':'blue', 'symbol':'circle'}
), ])

fig.show()

image.png

補足

3次元plot(等、恐らくWebGLが必要なもの?)が不要であれば、

print(pio.renderers.default)
Renderers configuration
-----------------------
    Default renderer: 'iframe'
    Available renderers:
        ['plotly_mimetype', 'jupyterlab', 'nteract', 'vscode',
         'notebook', 'notebook_connected', 'kaggle', 'azure', 'colab',
         'cocalc', 'databricks', 'json', 'png', 'jpeg', 'jpg', 'svg',
         'pdf', 'browser', 'firefox', 'chrome', 'chromium', 'iframe',
         'iframe_connected', 'sphinx_gallery', 'sphinx_gallery_png']

を色々変えれば表示されることが多いです。

追記

グラフのsvg表示や保存がうまくいかないこともある。環境によってはkaleidoを入れてもうまく動かないので、その場合はorcaを入れる。(requestsも必要。)

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?