Hello,
I have a simple heatmap made from the many good examples you have. It reads some json file to get the values for the x, y and colorbar axis.
import plotly.graph_objs as go
import json
import pandas as pd
from collections import OrderedDict
with open('swa-azimuth-timeseries.json', 'r') as f:
json_file = json.load(f)
data = json_file['data']
epochs = list(map(int, [item[0] for item in data]))
azimuths = list(map(float, [item[2] for item in data]))
electrons = list(map(float, [item[4] for item in data]))
epochs_as_string = [item[0] for item in data]
z_axis = [[float(item[4])] for item in data if item[0] in epochs_as_string]
bar = {
'tick0': 0,
'tickmode': 'array'
}
color = (
[0, "#00007F"],
[0.125, "#0000ff"],
[0.25, "#007FFF"],
[0.375, "#00ffff"],
[0.5, "#7FFF7F"],
[0.625, "#ffff00"],
[0.75, "#FF7F00"],
[0.875, "#ff0000"],
[1, "#7F0000"])
data = [go.Heatmap( x=epochs, y=azimuths, z=z_axis, colorscale=color, colorbar=bar)]
fig = go.Figure(data=data)
fig.update_layout(
title = 'Time Series example'
)
print(fig)
fig.show()
I believe the figure is correct:
Figure({
'data': [{'colorbar': {'tick0': 0, 'tickmode': 'array'},
'colorscale': [[0, '#00007F'], [0.125, '#0000ff'], [0.25,
'#007FFF'], [0.375, '#00ffff'], [0.5, '#7FFF7F'],
[0.625, '#ffff00'], [0.75, '#FF7F00'], [0.875,
'#ff0000'], [1, '#7F0000']],
'type': 'heatmap',
'x': [63745131000000, 63745131000000, 63745131000000, ...,
63745142300000, 63745142300000, 63745142300000],
'y': [5.625, 16.875, 28.125, ..., 331.875, 343.125, 354.375],
'z': [[3981.9308143034305], [4695.791109174329],
[3234.6012850072925], ..., [2053.76027406144],
[2399.8534297886836], [4356.079470806262]]}],
'layout': {'template': '...', 'title': {'text': 'Time Series example'}}
})
The JSON looks like this, very simple:
"data": [
[
"63745131000000",
"-42.1875",
"5.625",
"1.06811",
"3981.9308143034305"
],
[
"63745131000000",
"-42.1875",
"16.875",
"1.06811",
"4695.791109174329"
],
[
"63745131000000",
"-42.1875",
"28.125",
"1.06811",
"3234.6012850072925"
],
[
"63745131000000",
"-42.1875",
"39.375",
"1.06811",
"6389.844786765399"
],
[
"63745131000000",
"-42.1875",
"50.625",
"1.06811",
"6115.679777600199"
],
[
"63745131000000",
"-42.1875",
"61.875",
"1.06811",
"7486.080787986945"
],
[
"63745131000000",
"-42.1875",
"73.125",
"1.06811",
"4741.151907590278"
],
[
"63745131000000",
"-42.1875",
"84.375",
"1.06811",
"2059.7882348177613"
],
[
"63745131000000",
"-42.1875",
"95.625",
"1.06811",
"2566.031298380885"
],
[
"63745131000000",
"-42.1875",
"106.875",
"1.06811",
"3709.474486975868"
...
The z axis is a list of lists, it has all the values for a given epoch as you can see in the figure output.
When the plot is shown, it appears empty, even though it seems the axis are correct:
The idea I have is for epoch 1, there is an array of values which get plotted up this column on the y axis.
Any help would be appreciated. Perhaps the library is not sophisticated enough for this type of plotting?
Thanks