Skip to content

Commit eb42ced

Browse files
committed
Simplify install instructions and add plotting example
Remove hardcoded version from pip install command and add a matplotlib plotting example at the end of the README. Signed-off-by: Mathias L. Baumann <mathias.baumann@frequenz.com>
1 parent da122e0 commit eb42ced

File tree

1 file changed

+33
-3
lines changed

1 file changed

+33
-3
lines changed

README.md

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@ for a practical example of how to use the client.
3434
### Installation
3535

3636
```bash
37-
# Choose the version you want to install
38-
VERSION=0.18.0
39-
pip install frequenz-client-reporting==$VERSION
37+
pip install frequenz-client-reporting
4038
```
4139

4240

@@ -222,3 +220,35 @@ reporting-cli \
222220
--bounds
223221
```
224222
In addition to the default CSV format, individual samples can also be output using the `--format iter` option.
223+
224+
## Plotting data with matplotlib
225+
226+
```python
227+
import matplotlib.pyplot as plt
228+
import matplotlib.dates as mdates
229+
230+
# Fetch data (see examples above)
231+
data = [
232+
sample async for sample in
233+
client.receive_single_component_data(
234+
microgrid_id=1,
235+
component_id=100,
236+
metrics=[Metric.AC_ACTIVE_POWER],
237+
start_time=datetime.fromisoformat("2024-05-01T00:00:00"),
238+
end_time=datetime.fromisoformat("2024-05-02T00:00:00"),
239+
resampling_period=timedelta(seconds=60),
240+
)
241+
]
242+
243+
timestamps = [s.timestamp for s in data]
244+
values = [s.value for s in data]
245+
246+
fig, ax = plt.subplots(figsize=(14, 5))
247+
ax.plot(timestamps, values)
248+
ax.set_title("AC Active Power")
249+
ax.set_ylabel("Power (W)")
250+
ax.xaxis.set_major_formatter(mdates.DateFormatter("%H:%M"))
251+
ax.grid(True)
252+
fig.tight_layout()
253+
plt.show()
254+
```

0 commit comments

Comments
 (0)