MCPcopy Index your code
hub / github.com/secdev/scapy / plot

Method plot

scapy/plist.py:266–304  ·  view source on GitHub ↗

Applies a function to each packet to get a value that will be plotted with matplotlib. A list of matplotlib.lines.Line2D is returned. lfilter: a truth function that decides whether a packet must be plotted

(self,
             f,  # type: Callable[..., Any]
             lfilter=None,  # type: Optional[Callable[..., bool]]
             plot_xy=False,  # type: bool
             **kargs  # type: Any
             )

Source from the content-addressed store, hash-verified

264 return make_tex_table(self.res, *args, **kargs)
265
266 def plot(self,
267 f, # type: Callable[..., Any]
268 lfilter=None, # type: Optional[Callable[..., bool]]
269 plot_xy=False, # type: bool
270 **kargs # type: Any
271 ):
272 # type: (...) -> Line2D
273 """Applies a function to each packet to get a value that will be plotted
274 with matplotlib. A list of matplotlib.lines.Line2D is returned.
275
276 lfilter: a truth function that decides whether a packet must be plotted
277 """
278 # Defer imports of matplotlib until its needed
279 # because it has a heavy dep chain
280 from scapy.libs.matplot import (
281 plt,
282 MATPLOTLIB_INLINED,
283 MATPLOTLIB_DEFAULT_PLOT_KARGS
284 )
285
286 # Get the list of packets
287 if lfilter is None:
288 lst_pkts = [f(*e) for e in self.res]
289 else:
290 lst_pkts = [f(*e) for e in self.res if lfilter(*e)]
291
292 # Mimic the default gnuplot output
293 if kargs == {}:
294 kargs = MATPLOTLIB_DEFAULT_PLOT_KARGS
295 if plot_xy:
296 lines = plt.plot(*zip(*lst_pkts), **kargs)
297 else:
298 lines = plt.plot(lst_pkts, **kargs)
299
300 # Call show() if matplotlib is not inlined
301 if not MATPLOTLIB_INLINED:
302 plt.show()
303
304 return lines
305
306 def diffplot(self,
307 f, # type: Callable[..., Any]

Callers 4

diffplotMethod · 0.80
multiplotMethod · 0.80
world_traceMethod · 0.80

Calls 1

showMethod · 0.45

Tested by

no test coverage detected