Hello, I’m having trouble finding a way to plotting blood pressure. Ideally, I would like to have a floating box, where the upper limit of the box is the systolic pressure and the lower limit is diastolic. I’ve tried to use box plots but when they encounter zero values weird things start happening, whiskers disappear, values of adjacent bp disappear. I thought about waterfall plots but they depend on adjacent fields to set their value and that wouldn’t work. Any ideas would be greatly appreciated as I’m at my wits end. Thanks!
from plotly.offline import iplot, init_notebook_mode
init_notebook_mode()
import plotly.graph_objs as go
from plotly import tools
trace = []
trace2 = []
group_a = (['135.0', '96.0', '75.0'], ['133.0', '86.0', [0]], [[0], [0], [0]], ['133.0', '86.0', [0]])
x = (['10:00', '10:00', '10:00'], ['10:05', '10:05', '10:05'], ['10:10', '10:10', '10:10'], ['10:15', '10:15', '10:15'])
hr = [[63], [53], [0], [53]]
for i in range(0,len(group_a)):
trace.append(go.Box(y= group_a[i],
x=x[i],
name="BP",
hoverinfo='none'))
for a in range(0,len(hr)):
trace2.append(go.Scatter(y= hr[a],
x=x[a],
name='Heart rate at Time x',
marker=dict(size=[20]),
text=['(Time, hr)']))
# layout = go.Layout(
# yaxis=go.layout.YAxis(
# title='Blood Pressure',
# range=[0, 180]))
fig = tools.make_subplots(rows =1,
cols =2)
fig.append_trace(trace[0],1,1)
fig.append_trace(trace2[0],1,1)
fig.append_trace(trace[1],1,1)
fig.append_trace(trace2[1],1,1)
fig.append_trace(trace[2],1,1)
fig.append_trace(trace2[2],1,1)
fig.update_yaxes(title_text="Blood Presure", row=1, col=1)
fig.update_xaxes(title_text="Time", row=1, col=1)
fig.layout.update(title='Blood Pressure',
showlegend=False)
iplot(fig)