From 2efe4bc1a966da188da450782d8d74690933526b Mon Sep 17 00:00:00 2001 From: Mitja Felicijan Date: Tue, 1 Aug 2023 17:08:37 +0200 Subject: Note: SVG charts with matplotlib --- ...23-08-01-make-b-w-svg-charts-with-matplotlib.md | 51 ++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 content/notes/2023-08-01-make-b-w-svg-charts-with-matplotlib.md (limited to 'content/notes/2023-08-01-make-b-w-svg-charts-with-matplotlib.md') 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 @@ +--- +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) -- cgit v1.2.3