pymzML
pymzML copied to clipboard
Plotting spectra with annotations has hiccups
Describe the bug After plotting a spectrum with multiple annotations and deselecting some of annotations in random order will give funny results. Might have to do with the way we are currently plotting data.
Solution Instead of duplicating each data point three times (1. normal data point (mz/i), 2. zero I data point (mz, 0) and 3. line breaking point (mz+x, None) ) we could "misuse" the error bars.
This example will produce the wanted "stick" representation with only one data point and stops plotly to be confused about annotations:
go.Scatter(
x=ldf['mz'],
y=ldf['Intensity'],
name='{0}@{score}: {seq#mod}'.format(k, **v),
mode="markers+text",
marker={
'size': 1,
},
marker_color=color_set[pos][0],
line = {
'color': color_set[pos][0],
'width': 0.5
},
error_y={
'type': 'data',
'symmetric': False,
'arrayminus': ldf['Intensity'],
'visible': True,
'thickness': 1,
'width': 1
},
text=ldf['{0}_annotation'.format(k)],
textfont = {
'color': color_set[pos][0],
},
)