Skip to content

Commit fe0060e

Browse files
authored
Update README.md
1 parent 58cbeea commit fe0060e

File tree

1 file changed

+69
-31
lines changed

1 file changed

+69
-31
lines changed

README.md

Lines changed: 69 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,57 @@
11
# Interactive Console-based Time Window Plotter
22

3-
Terminal Plotter is script that reads numeric data from a file (by default `data.txt`) and displays it as a live-updating plot in the terminal using [plotext](https://pypi.org/project/plotext/). The plot shows a moving time window (TW) of the data, and you can interactively adjust the window's size and position using keyboard controls.
3+
Terminal Plotter is a scripts that reads numeric data from a file (by default `data.txt`) and displays a live-updating plot in your terminal using [plotext](https://pypi.org/project/plotext/). The plot shows a moving time window (TW) of your data along with its running average. The script provides interactive controls to adjust the time window, modify the running average window, and toggle the visibility of each plotted line.
44

55
<img width="1408" alt="image" src="https://github.com/user-attachments/assets/fd7218a5-e979-43ab-bbec-5e0be94a39b5" />
66

7-
87
## Features
98

10-
- **Live Plotting:**
11-
Continuously reads new data from a file and updates the plot in real time.
12-
13-
- **Moving Time Window:**
14-
Displays only the last X data points (a configurable "time window").
15-
16-
- **Interactive Controls:**
17-
Adjust the plot on the fly using these keys:
18-
- `k`: Increase window size by **1**
19-
- `K`: Increase window size by **100**
20-
- `j`: Decrease window size by **1** (minimum window size is 1)
21-
- `J`: Decrease window size by **100** (minimum window size is 1)
22-
- `h`: Move the window to older data (shift left) by the current window size
23-
- `H`: Move the window to older data by **100** points
24-
- `l`: Move the window to newer data (shift right) by the current window size
25-
- `L`: Move the window to newer data by **100** points
26-
- `q`: Quit the program
27-
28-
- **Auto-Scrolling:**
29-
When the plot is showing the latest data (the last TW), new data automatically scrolls into view.
30-
31-
- **Legend Display:**
32-
The plot includes a legend on top displaying the current time window length.
9+
- **Live Plotting:** Continuously updates the plot as new data is added to the file.
10+
- **Moving Time Window:** Displays only a subset of the full dataset.
11+
*Default TW length is 10 points.*
12+
- **Running Average:**
13+
Computes and plots a running average for the data in the current time window.
14+
*Default running average window is 5 points.*
15+
- **Interactive Controls:**
16+
- **Time Window Adjustments:**
17+
- `k`: Increase window size by 1.
18+
- `K`: Increase window size by 100.
19+
- `j`: Decrease window size by 1 (minimum 1).
20+
- `J`: Decrease window size by 100 (minimum 1).
21+
- **Scrolling:**
22+
- `h`: Scroll backward (older data) by the current window size.
23+
- `H`: Scroll backward by 100.
24+
- `l`: Scroll forward (newer data) by the current window size.
25+
- `L`: Scroll forward by 100.
26+
- **Running Average Adjustments:**
27+
- `r`: Increase running average window by 1.
28+
- `R`: Increase running average window by 10.
29+
- `f`: Decrease running average window by 1 (minimum 1).
30+
- `F`: Decrease running average window by 10 (minimum 1).
31+
- **Toggle Line Visibility:**
32+
- `1`: Toggle the raw data line on/off.
33+
- `2`: Toggle the running average line on/off.
34+
- **Quit:**
35+
- `q`: Quit the program.
36+
37+
The legend in the plot updates with the current settings (e.g., TW length, running average window, and which lines are visible).
3338

3439
## Installation
3540

36-
1. **Python 3:**
37-
Ensure you have Python 3 installed on your Unix-like system (Linux, macOS). This script uses the `termios` and `tty` modules, which are available on Unix.
41+
1. **Prerequisites:**
42+
Ensure you have Python 3 installed on your system.
3843

3944
2. **Install Dependencies:**
40-
Install the `plotext` package using pip:
45+
The script uses the [plotext](https://pypi.org/project/plotext/) library. Install it using pip:
4146
```bash
4247
pip install plotext
43-
```
48+
```
4449

4550
## Usage
4651
Run the script from your terminal. It supports several command-line options:
4752

48-
`python a.py [--window WINDOW] [--file FILE] [--interval INTERVAL]`
53+
`python a.py [--window WINDOW] [--file FILE] [--interval INTERVAL] [--avg-window AVG_WINDOW]`
54+
4955

5056
## Command-line Options
5157
`-w / --window`
@@ -57,13 +63,45 @@ Specify the path to the data file (default: data.txt).
5763
`-i / --interval`
5864
Set the refresh interval in seconds (default: 2 seconds).
5965

66+
`-a, --avg-window`
67+
Window size for running average (default: 5).
68+
69+
70+
## Interactive Controls
71+
72+
While the script is running, you can interact with the plot using the following keys:
73+
74+
75+
Time Window Adjustments:
76+
77+
78+
- k / K: Increase window size by 1 or 100.
79+
- j / J: Decrease window size by 1 or 100.
80+
- Scrolling:
81+
- h / H: Scroll backward by the current window size or 100.
82+
- l / L: Scroll forward by the current window size or 100.
83+
- Running Average Adjustments:
84+
- r / R: Increase running average window by 1 or 10.
85+
- f / F: Decrease running average window by 1 or 10.
86+
- Toggle Line Visibility:
87+
- 1: Toggle the raw data line on/off.
88+
- 2: Toggle the running average line on/off.
89+
- Quit:
90+
- q: Quit the program.
6091

6192
## Example
6293

6394
### Run the script
6495
First, Run the script with a 20-point window, reading from mydata.txt, and updating every 1.5 seconds:
6596

66-
`python a.py -w 20 -f mydata.txt -i 1.5`
97+
`python a.py --window 20 --file mydata.txt --interval 1.5 --avg-window 5`
98+
99+
100+
101+
102+
103+
104+
67105

68106

69107
### Feeding Data to the Plot

0 commit comments

Comments
 (0)