Reputation: 651
I wanted to create a heatmap of a probability density matrix using plotly.
import numpy as np
from plotly.offline import download_plotlyjs, init_notebook_mode, plot
import plotly.graph_objs as go
probability_matrix = np.loadtxt("/path/to/file")
trace = go.Heatmap(z = probability_matrix)
data=[trace]
plot(data, filename='basic-heatmap')
This gives me an image like this:
But after printing the image on a piece of paper, it looks very dark (color printing) and becomes completely indiscernible after black and white printing. I was wondering if I could change the color range arbitrarily; so that the whole image looks a bit softer or lighter.
For example: 1 could be white and 0 could be very light blue or a softer color; so that the whole image looks more lighter after printing on a paper.
Note: not sure if this should be a separate question, since I have asked another question related to plotly here.
Upvotes: 1
Views: 5759
Reputation: 252
You will need to manually insert a colour scale
trace = go.Heatmap(z=probability_matrix, colorscale=[[0.0, '#F5FFFA'],
[0.2, '#ADD8E6'],
[0.4, '#87CEEB'],
[0.6, '#87CEFA'],
[0.8, '#40E0D0'],
[1.0, '#00CED1']])
data=[trace]
Upvotes: 5