code: def _plotting_decimation(trace, max_len=10e5, decimation_step=4):
      
      trace_len = trace.stats.npts
      while trace_len > max_len:
          trace.decimate(decimation_step)
          trace_len = trace.stats.npts
      return trace
docs: Decimate data until required length reached.
  
      :type trace: obspy.core.stream.Trace
      :param trace: Trace to decimate
      type max_len: int
      :param max_len: Maximum length in samples
      :type decimation_step: int
      :param decimation_step: Decimation factor to use for each step.
  
      :return: obspy.core.stream.Trace
  
      .. rubric: Example
  
      >>> from obspy import Trace
      >>> import numpy as np
      >>> trace = Trace(np.random.randn(1000))
      >>> trace = _plotting_decimation(trace, max_len=100, decimation_step=2)
      >>> print(trace.stats.npts)
      63