I would like to remove the top boundary line that is displayed above the horizontal arrow line in a seaborn plot. Currently, the plot includes an arrow line, and there is a visible boundary line positioned above it. I would like to eliminate this top boundary line.
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
from matplotlib.patches import FancyArrowPatch
sns.set(style="ticks", font_scale=1.2)
np.random.seed(42)
num_values = 4
data = {
'TR': [chr(ord('A') + i) for i in range(num_values)],
'Value': np.random.randint(10, 30, size=num_values)
}
df = pd.DataFrame(data)
fig, ax = plt.subplots(figsize=(5, 7))
i = 'Value'
palette = sns.color_palette("Set1", len(df))
g = sns.barplot(x='TR', y=i, palette=palette, edgecolor="white", errcolor="black",
errorbar='sd', zorder=10, data=df)
ax.set_ylim([0.9*df[i].min(), 1.1*df[i].max()])
sns.despine(ax=ax)
height = 30
bar1 = g.containers[0][0]
bar2 = g.containers[0][2]
arrow = FancyArrowPatch((bar1.get_x() + bar1.get_width()/2, height),
(bar2.get_x() + bar2.get_width()/2, height),
arrowstyle='|-|', mutation_scale=10, linewidth=1.5, color='black',
connectionstyle='angle, angleA=90, angleB=0, rad=0')
ax.add_patch(arrow)
plt.tight_layout()
plt.show()
It should resemble the figure shown below.