LoginSignup
24
23

More than 5 years have passed since last update.

plotly でいい感じのグラフをオンラインに公開する

Last updated at Posted at 2015-07-14

Jupyter でずらずらページをつくるのがイイとは思うけどグラフだけほしいときにつかえそう

https://plot.ly/

これとかよむ

つかいかた

つかうには api_key が必要なのでもらう

signup には github のアカウントがつかえます

api_key を取得したら

pip install plotly

すると .plotly\.credentials ができるので そこに username と api_key をセットしておく

これをやる Getting Started Plotly for Python

import plotly.plotly as py
from plotly.graph_objs import *

trace0 = Scatter(
    x=[1, 2, 3, 4],
    y=[10, 15, 13, 17]
)

trace1 = Scatter(
    x=[1, 2, 3, 4],
    y=[16, 5, 11, 9]
)

data = Data([trace0, trace1])
unique_url = py.plot(data, filename = 'basic-line')

py.plot で URL が発行されてページが開く

https://plot.ly/~trsqxyz/3

データやコードも読めるので便利

画像がきれいなのでローカルでもできたらいいなと思っている

2015/07/14 10:10

layout = Layout(title='basic-line')
fig = Figure(data=data, layout=layout)
py.image.save_as(fig, filename='fig.png')

でローカル保存できた

24
23
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
24
23