I’m making an application that plays a video of a sim alongside the data that was collected during the run. I’ve done this successfully for 2 other graphs, however the ecg graph is compressing itself to a small portion of the allotted space (see image)
Initially I assumed this was a refresh rate issue. I have reduced the graph update speed to every 5 seconds and I’m still seeing this issue.
Relevant code below:
if len(ECG.index) == 0: #This way we only read the data at the beginning and not each time
ECG = pd.read_csv("assets/Session/Project1/ECG.csv")
relativetimes = [np.float64(i)-seconds[0] for i in ECG['Timestamp'].tolist()]
ecgtimestamps = [str(int(i // 60)) + ":" + "{:.1f}".format(i % 60) for i in relativetimes]
else:
e = 2 #exists as debug point
for i in range(0, len(relativetimes)-1):
if relativetimes[i] >= currentDTime: #currentDTims is the time of the video
row = i
break
showSet = ECG.loc[0:i] # currently showing all values up to the moment
relShowTimes = relativetimes[0:i+1]
showTSs = ecgtimestamps[0:i+1]
ecgvals = [ecgtimestamps[x] for x in range(0, len(ecgtimestamps)-1, 100)] # only showing every 100 time stamps
# Create a scatter plot object for the data.
ecg = pgo.Scatter(x=showTSs, y=showSet['Sample'], mode='lines', name='ECG')
# Remake the ECG figure with the new data set
FECG = pgo.Figure(data=[ecg],
layout=pgo.Layout(
xaxis=dict(range=[0, len(showSet.index)],
tickangle=60,
# 60 degree tilt on the ticks looks good and adds space
tickvals=ecgvals, ticktext=ecgvals, # show ticks only at peaks
gridcolor=gridlines),
yaxis=dict(range=[min(showSet.Sample.values),
# y max and min are set to the data max and min
max(showSet.Sample.values)],
gridcolor=gridlines),
margin=dict(l=30, r=20, t=5, b=20), # Experimentally found margins
template=theme, paper_bgcolor=paper)
)