Coverage for src / tracekit / visualization / plot.py: 71%

14 statements  

« prev     ^ index     » next       coverage.py v7.13.1, created at 2026-01-11 23:04 +0000

1"""Plotting functions namespace. 

2 

3This module provides a namespace for plot functions to support: 

4 from tracekit.visualization import plot 

5 plot.plot_trace(trace) 

6 

7Re-exports main plotting functions. 

8""" 

9 

10from __future__ import annotations 

11 

12from typing import TYPE_CHECKING, Any 

13 

14if TYPE_CHECKING: 

15 from tracekit.core.types import WaveformTrace 

16 

17from tracekit.visualization.digital import ( 

18 plot_logic_analyzer, 

19 plot_timing, 

20) 

21from tracekit.visualization.eye import ( 

22 plot_bathtub, 

23 plot_eye, 

24) 

25from tracekit.visualization.interactive import ( 

26 plot_bode, 

27 plot_histogram, 

28 plot_phase, 

29 plot_waterfall, 

30) 

31from tracekit.visualization.spectral import ( 

32 plot_fft, 

33 plot_psd, 

34 plot_spectrogram, 

35 plot_spectrum, 

36) 

37from tracekit.visualization.waveform import ( 

38 plot_multi_channel, 

39 plot_waveform, 

40 plot_xy, 

41) 

42 

43 

44def plot_trace(trace: WaveformTrace, **kwargs: Any) -> Any: 

45 """Plot a trace using plot_waveform. 

46 

47 Convenience alias for plot_waveform. 

48 

49 Args: 

50 trace: Waveform trace to plot. 

51 **kwargs: Additional arguments passed to plot_waveform. 

52 

53 Returns: 

54 Matplotlib axes object. 

55 """ 

56 return plot_waveform(trace, **kwargs) 

57 

58 

59def add_annotation(text: str, **kwargs: Any) -> None: 

60 """Add annotation to current plot. 

61 

62 Placeholder for annotation functionality. 

63 

64 Args: 

65 text: Annotation text. 

66 **kwargs: Additional arguments passed to ax.annotate. 

67 """ 

68 import matplotlib.pyplot as plt 

69 

70 ax = plt.gca() 

71 ax.annotate(text, xy=(0.5, 0.95), xycoords="axes fraction", **kwargs) 

72 

73 

74__all__ = [ 

75 "add_annotation", 

76 "plot_bathtub", 

77 "plot_bode", 

78 "plot_eye", 

79 "plot_fft", 

80 "plot_histogram", 

81 "plot_logic_analyzer", 

82 "plot_multi_channel", 

83 "plot_phase", 

84 "plot_psd", 

85 "plot_spectrogram", 

86 "plot_spectrum", 

87 "plot_timing", 

88 "plot_trace", 

89 "plot_waterfall", 

90 "plot_waveform", 

91 "plot_xy", 

92]