I have a following code that plots three lines into one graph in matplotlib:
import pandas as pd
import matplotlib.pylab as plt
df = pd.read_csv("balici_naskladnovaci.csv")
df = df.sort_values(by = "interval start")
df["interval start"] = pd.to_datetime(df["interval start"])
# balici
fig, ax = plt.subplots()
ax.plot(
df[df["expedice"] == "liberec"]["interval start"].astype(str),
df[df["expedice"] == "liberec"]["balici"],
color="red",
label="Liberec",
)
ax.plot(
df[df["expedice"] == "jablonec"]["interval start"].astype(str),
df[df["expedice"] == "jablonec"]["balici"],
color="blue",
label="Jablonec",
)
ax.plot(
df[df["expedice"] == "lipa"]["interval start"].astype(str),
df[df["expedice"] == "lipa"]["balici"],
color="green",
label="Lípa",
)
ax.set_ylabel("Počet baličů", color="black", fontsize=14)
plt.title("Balici napric expedicemi")
plt.tight_layout()
fig.legend()
plt.show()
But the result is very strange, because of these horizontal lines:
Do you know, how can I fix it please?
