Plotter module provides functions to generate publication-quality figures of time-series signals organized by arbitration ID, cluster membership, or J1979 PID.
Configuration
Module-level constants control output format:Functions
plot_j1979
Timer instance for performance tracking
J1979 dictionary from PreProcessor (maps PIDs to
J1979 objects)If True, regenerate plots even if output folder exists
- Single figure file:
j1979/<format>(e.g.,j1979.png) - One subplot per PID with title “PID 0xXX: [description]”
- Black time-series line plots
- Shared x-axis (time)
- Creates
j1979/folder if it doesn’t exist - Skips plotting if folder exists and
force=False - Each subplot shows the PID value over time
- Figure height scales with number of PIDs (1.3 inches per PID + 1 inch padding)
plot_signals_by_arb_id
Timer instance for performance tracking
Arbitration ID dictionary from PreProcessor
Signal dictionary from
generate_signals()If True, regenerate plots even if output folder exists
- One figure per non-static arbitration ID:
figures/0xXXX.<format> - Subplots:
- One per signal (normalized time series)
- Final subplot: TANG (Transition Aggregation N-Gram)
- TANG visualization:
- Black circles: Non-zero transition frequency bits
- Gray triangles: Padding bits (zero frequency)
- Dashed vertical lines: Signal boundaries
- Creates
figures/folder if it doesn’t exist - Skips static arbitration IDs (all constant signals)
- Figure height scales with number of signals
- Subplot titles show signal metadata (bit range, entropy, etc.)
plot_signals_by_cluster
Timer instance for performance tracking
Cluster dictionary from
greedy_signal_clustering() or label_propagation()Signal dictionary from
generate_signals() (with optional J1979 labels)If True, include J1979 PID labels in subplot titles (if available)
If True, regenerate plots even if output folder exists
- One figure per cluster:
clusters/cluster_<ID>.<format> - One subplot per signal in cluster
- Subplot titles:
- Without J1979: “Arb ID 0xXXX [start:stop] (Shannon: X.XX)”
- With J1979: “Arb ID 0xXXX [start:stop] [PID_NAME (PCC:0.XX)]”
- Creates
clusters/folder if it doesn’t exist - Skips plotting if folder exists and
force=False - Figure height scales with cluster size
- Useful for semantic interpretation (correlated signals visualized together)
Usage Examples
Basic Plotting
Complete Pipeline with Plotting
Customizing Figure Format
To change output format globally, modify the module constants before importing:Output Structure
After running all plotting functions:Visualization Details
TANG Plot (in Arb ID Figures)
The TANG (Transition Aggregation N-Gram) subplot shows:- X-axis: Bit position (0 to payload length in bits)
- Y-axis: Normalized transition frequency (0.0 to 1.0)
- Black circles: Active signal bits
- Gray triangles: Padding/static bits
- Dashed vertical lines: Signal token boundaries
- Horizontal plateaus suggest bits belonging to the same signal
- Sudden jumps indicate signal boundaries
- Low values near zero indicate padding or static bits
Signal Subplots
Each signal subplot includes:- Title: Signal metadata (Arb ID, bit range, entropy, optional J1979 label)
- X-axis: Time (from CAN log timestamps)
- Y-axis: Normalized signal value (0.0 to 1.0 after min-max scaling)
- Line color: Black (consistent across all plots)
Cluster Plots
Cluster visualization helps identify:- Semantic relationships: Signals in the same cluster are highly correlated
- Visual similarity: Correlated signals have similar waveforms
- J1979 mapping: Labels show which signals correspond to known PIDs
- Cluster with “Vehicle Speed” label → Speedometer-related signals
- Cluster with “Engine RPM” label → Tachometer-related signals
- Cluster with no J1979 label → Proprietary signal group (e.g., tire pressure, gear position)
Performance Considerations
- Force Flag: Set
force=Trueto regenerate plots,force=Falseto skip if folder exists - File Format:
- PNG: Fast, good for previews (default)
- EPS: Vector format, preferred for publications
- PDF: Vector format, good for reports
- DPI: Higher values (600+) for print, lower (300) for screen
- Figure Size: Automatically scales with number of subplots
- Memory: Each figure is closed after saving to free memory
Troubleshooting
No Plots Generated
Cause: Output folder exists andforce=False
Solution: Set force=True or manually delete output folders
Empty Figures
Cause: All signals are static or no signals extracted Solution: Check tokenization parameters and DLC filtering in PreProcessorTypo in savefig
Note: There’s a typo in the source code (bbox_iches should be bbox_inches). This is a known issue in the original implementation and does not affect functionality.