LoginSignup
6
6

More than 5 years have passed since last update.

plotly でいい感じのグラフをつくる

Last updated at Posted at 2015-07-23

plotly のつかいかた

前回からつかってみてだいぶ慣れたのでつづき
trace にデータセットして Data でまとめるという感じ

scatter.png

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

trace = Scatter(x=list(range(10)), y=list(np.random.randint(0,30,10)))
data = Data([trace])
py.image.save_as(data, filename='scatter.png')

bar.png

bar
trace = Bar(x=list(range(10)), y=list(np.random.randint(0,30,10)))
data = Data([trace])
py.image.save_as(data, filename='bar.png')

histogram.png

histogram
trace = Histgram(x=np.random.randn(500))
data = Data([trace])
py.image.save_as(data, filename='histogram.png')

heatmap.png

heatmap
trace = Heatmap(
    z=[np.random.randint(1,50,50) for _ in range(50)],
    colorscale='YIGnBu',
)
data = Data([trace])
py.image.save_as(data, filename='heatmap.png')

bar_scatter.png

multiple_chart
trace = Bar(x=list(range(8)), y=list(np.random.randint(0,10,8)))
trace2 = Scatter(x=list(range(8)), y=list(np.random.randint(0,10,8)))
data = Data([trace, trace2])
py.image.save_as(data, filename='multiple.png')

fap.png

field_area_plots
trace = Scatter(
    x=list(range(8)),
    y=list(np.random.randint(0,10,8)),
    fill='tonexty',
    mode='none'
)
trace2 = Scatter(
    x=list(range(8)),
    y=list(np.random.randint(0,10,8)),
    fill='tonexty',
    mode='none'
)
data = Data([trace, trace2])
py.image.save_as(data, 'field_area_plots.png')
6
6
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
6
6