diffplot(f, delay=1, lfilter=None) Applies a function to couples (l[i],l[i+delay]) A list of matplotlib.lines.Line2D is returned.
(self,
f, # type: Callable[..., Any]
delay=1, # type: int
lfilter=None, # type: Optional[Callable[..., bool]]
**kargs # type: Any
)
| 304 | return lines |
| 305 | |
| 306 | def diffplot(self, |
| 307 | f, # type: Callable[..., Any] |
| 308 | delay=1, # type: int |
| 309 | lfilter=None, # type: Optional[Callable[..., bool]] |
| 310 | **kargs # type: Any |
| 311 | ): |
| 312 | # type: (...) -> Line2D |
| 313 | """diffplot(f, delay=1, lfilter=None) |
| 314 | Applies a function to couples (l[i],l[i+delay]) |
| 315 | |
| 316 | A list of matplotlib.lines.Line2D is returned. |
| 317 | """ |
| 318 | # Defer imports of matplotlib until its needed |
| 319 | # because it has a heavy dep chain |
| 320 | from scapy.libs.matplot import ( |
| 321 | plt, |
| 322 | MATPLOTLIB_INLINED, |
| 323 | MATPLOTLIB_DEFAULT_PLOT_KARGS |
| 324 | ) |
| 325 | |
| 326 | # Get the list of packets |
| 327 | if lfilter is None: |
| 328 | lst_pkts = [f(self.res[i], self.res[i + 1]) |
| 329 | for i in range(len(self.res) - delay)] |
| 330 | else: |
| 331 | lst_pkts = [f(self.res[i], self.res[i + 1]) |
| 332 | for i in range(len(self.res) - delay) |
| 333 | if lfilter(self.res[i])] |
| 334 | |
| 335 | # Mimic the default gnuplot output |
| 336 | if kargs == {}: |
| 337 | kargs = MATPLOTLIB_DEFAULT_PLOT_KARGS |
| 338 | lines = plt.plot(lst_pkts, **kargs) |
| 339 | |
| 340 | # Call show() if matplotlib is not inlined |
| 341 | if not MATPLOTLIB_INLINED: |
| 342 | plt.show() |
| 343 | |
| 344 | return lines |
| 345 | |
| 346 | def multiplot(self, |
| 347 | f, # type: Callable[..., Any] |