aboutsummaryrefslogtreecommitdiff
path: root/content/notes/2023-08-01-make-b-w-svg-charts-with-matplotlib.md
blob: 50c380612ebb4ce98912d1c209e35b7f90de6b2b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
---
title: "Make B/W SVG charts with matplotlib"
url: make-b-w-svg-charts-with-matplotlib.html
date: 2023-08-01T17:04:10+02:00
type: note
draft: false
---

Install pip requirements.

```sh
pip install matplotlib
pip install numpy
pip install pandas
```

Now execute the script.

```python
import csv
import sys

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd

# Read the data
df = pd.read_csv("data.csv")

# Settings
plt.title("Connect median NLB vs ALB")
fig = plt.gcf()
fig.set_size_inches(10, 4)

# Plotting
plt.plot(df["Epoch"], df["Connect (ALB)"], label = "ALB", color="black", linestyle="-")
plt.plot(df["Epoch"], df["Connect (NLB)"], label = "NLB", color="black", linestyle="--")

# Adding x and y axis labels
plt.xlabel("Epoch", fontstyle="italic")
plt.ylabel("Median value (ms)", fontstyle="italic")

# Legend
legend = plt.legend()
legend.get_frame().set_linewidth(0)

# Export as SVG
plt.savefig("plot.svg", format="svg")
```

![SVG Chart](/notes/plot.svg)