0

I've some datasetfor which I'm using seaborn catplot of kind=box.

import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
vertdf_dir = pd.read_csv(folder + "/" + filename)
meandf_dir = pd.DataFrame(columns=["NumFlights", "fix", "delay"])


k = 0
for i in vertdf_dir["num Flights"].unique():
    for j in vertdf_dir.fix.unique():
        meandf_dir.loc[k,"NumFlights"] = i
        meandf_dir.loc[k,"fix"] = j
        meandf_dir.loc[k,"delay"] = vertdf_dir[(vertdf_dir["num Flights"]==i) & (vertdf_dir.fix==j)].mean().Delay
        k += 1

sns.catplot(data=vertdf_dir, x="fix", y="Delay", hue="num Flights", kind="box", showmeans=True)

dataplot

In the plot I would like to show a trend where for each "num Flights", as fix increases delay goes down.

Is there a way I can draw a line connecting the mean values(green triangles) for each "num flights"?

The questions mentioned here, here and here talk about adding lineplots for the boxplots. The category function creates problem like shown in these undesirable plots.

  • please provide a fully reproducible example with correct formatting – mozway Jan 27 '23 at 06:22
  • @mozway Hello, I've explained that the question I've asked differs from the suggested answers as they are on boxplot, and mine is a category plot using kind=box. – rrsaxena92 Jan 27 '23 at 10:51

0 Answers0