Plotly Heatmap Summary

Posted on April 11, 2017 by Shota Nagayama
Tags: python

how to start

https://plot.ly/python/getting-started/

online mode

offline mode

import plotly.offline as py

Basic functions

heatmaps

import plotly.offline as py
import plotly.graph_objs as go

trace = go.Heatmap(z=[[1, 20, 30, 50, 1], [20, 1, 60, 80, 30], [30, 60, 1, -10, 20]],
                   x=['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'],
                   y=['Morning', 'Afternoon', 'Evening'])
data=[trace]
py.plot(data, filename='labelled-heatmap')

z is the value corresponding to every set of x and y. The most outer list of the nested nest describes sets of data placed horizontaly, from the bottom to up. Each inner list shows data of each row from left to right.

Actually everything looks build from dict.

import plotly.offline as py
import plotly.graph_objs as go

py.plot(
	dict( # Structed as go.Heatmap. good name to declare this dict as a variable is "figure"
		data=[ # Structed as go.Heatmap
			dict(z=, x=, y=, type='heatmap', colorscale='Viridis'), # First graph to show by the heatmap in the figure.
			dict(x= -x+x[0], y= y-y[0]+yshift, line =dict(color='white',width=3)), # Second graph to show in the figure. Different graph types are acceptable in a figure.
			dict(), # Third
			dict() # Forth.....Nth
		],
		layout=dict( # Defines settings # Structed as go.Layout
			margin=dict(t=200,r=200,b=200,l=200),
			title='GitHub commits per day',
			xaxis=dict(ticks='', nticks=36),
			yaxis=dict(ticks='' ),
			showlegend=Bool,
			width=,
			height=,
			autosize=Bool
		) 
	),
	filename="foobar",
	height=750
)

Multiple sets of data can be accepted by the list of the first argument of plot().