diff --git a/docs/source/user_guide/interactive_plots.rst b/docs/source/user_guide/interactive_plots.rst index 428981568..fb2d47ed8 100644 --- a/docs/source/user_guide/interactive_plots.rst +++ b/docs/source/user_guide/interactive_plots.rst @@ -19,7 +19,6 @@ interactively zoomed-in if you execute the code in a notebook import holoviews.operation.datashader as hd from holoviews.plotting.util import process_cmap from holoviews import opts, dim - import sys hv.extension("bokeh") @@ -29,13 +28,20 @@ interactively zoomed-in if you execute the code in a notebook loadopts.setMSLevels([1]) loadopts.setSkipXMLChecks(True) loadopts.setIntensity32Bit(True) - loadopts.setIntensityRange(oms.DRange1(oms.DPosition1(5000), oms.DPosition1(sys.maxsize))) loader.setOptions(loadopts) loader.load("../../../src/data/BSA1.mzML", exp) + + # Filter out low-intensity peaks using ThresholdMower + threshold_filter = oms.ThresholdMower() + params = threshold_filter.getDefaults() + params.setValue(b"threshold", 5000.0) + threshold_filter.setParameters(params) + threshold_filter.filterPeakMap(exp) + exp.updateRanges() expandcols = ["RT", "mz", "inty"] spectraarrs2d = exp.get2DPeakDataLong( - exp.getMinRT(), exp.getMaxRT(), exp.getMinMZ(), exp.getMaxMZ() + exp.getMinRT(), exp.getMaxRT(), exp.getMinMZ(), exp.getMaxMZ(), 1 ) spectradf = pd.DataFrame(dict(zip(expandcols, spectraarrs2d))) spectradf = spectradf.set_index(["RT", "mz"]) @@ -75,17 +81,14 @@ interactively zoomed-in if you execute the code in a notebook min_alpha=0, ) .opts(active_tools=["box_zoom"], tools=["hover"], hooks=[new_bounds_hook]) - .opts( # weird.. I have no idea why one has to do this. But with one opts you will get an error - plot=dict( - width=800, - height=800, - xlabel="Retention time (s)", - ylabel="mass/charge (Da)", - ) - ) ) - hd.dynspread(raster, threshold=0.7, how="add", shape="square") + hd.dynspread(raster, threshold=0.7, how="add", shape="square").opts( + width=800, + height=800, + xlabel="Retention time (s)", + ylabel="mass/charge (Da)", + ) Result: