aboutsummaryrefslogtreecommitdiff
path: root/content
diff options
context:
space:
mode:
authorMitja Felicijan <m@mitjafelicijan.com>2023-08-01 17:08:37 +0200
committerMitja Felicijan <m@mitjafelicijan.com>2023-08-01 17:08:37 +0200
commit2efe4bc1a966da188da450782d8d74690933526b (patch)
treedc43e7c598db27537053bc900e93eef68a8c3d25 /content
parenta64284a4ae72c4f4d6e5a6aa18337cbc5cc1247c (diff)
downloadmitjafelicijan.com-2efe4bc1a966da188da450782d8d74690933526b.tar.gz
Note: SVG charts with matplotlib
Diffstat (limited to 'content')
-rw-r--r--content/notes/2023-08-01-make-b-w-svg-charts-with-matplotlib.md51
1 files changed, 51 insertions, 0 deletions
diff --git a/content/notes/2023-08-01-make-b-w-svg-charts-with-matplotlib.md b/content/notes/2023-08-01-make-b-w-svg-charts-with-matplotlib.md
new file mode 100644
index 0000000..50c3806
--- /dev/null
+++ b/content/notes/2023-08-01-make-b-w-svg-charts-with-matplotlib.md
@@ -0,0 +1,51 @@
1---
2title: "Make B/W SVG charts with matplotlib"
3url: make-b-w-svg-charts-with-matplotlib.html
4date: 2023-08-01T17:04:10+02:00
5type: note
6draft: false
7---
8
9Install pip requirements.
10
11```sh
12pip install matplotlib
13pip install numpy
14pip install pandas
15```
16
17Now execute the script.
18
19```python
20import csv
21import sys
22
23import matplotlib.pyplot as plt
24import numpy as np
25import pandas as pd
26
27# Read the data
28df = pd.read_csv("data.csv")
29
30# Settings
31plt.title("Connect median NLB vs ALB")
32fig = plt.gcf()
33fig.set_size_inches(10, 4)
34
35# Plotting
36plt.plot(df["Epoch"], df["Connect (ALB)"], label = "ALB", color="black", linestyle="-")
37plt.plot(df["Epoch"], df["Connect (NLB)"], label = "NLB", color="black", linestyle="--")
38
39# Adding x and y axis labels
40plt.xlabel("Epoch", fontstyle="italic")
41plt.ylabel("Median value (ms)", fontstyle="italic")
42
43# Legend
44legend = plt.legend()
45legend.get_frame().set_linewidth(0)
46
47# Export as SVG
48plt.savefig("plot.svg", format="svg")
49```
50
51![SVG Chart](/notes/plot.svg)