1

I am trying to combine a bar chart(with hue) and line plot (with hue). I am able to plot them separately. But together, I get some garbage graph.

Code:

import matplotlib
import matplotlib.pyplot as plt
import seaborn as sns

matplotlib.rc_file_defaults()
ax1 = sns.set_style(style=None, rc=None )

fig, ax1 = plt.subplots(figsize=(12,6))


sns.barplot(data = dd, x='time', y='c',hue="p", alpha=0.5)

ax2 = ax1.twinx()
sns.lineplot(x="time", y="a", hue="p", data=dd, marker="o",ax=ax2)

Result Graph

Bar Graph Separate

Line Plot Separate

How do I fix this?

  • 1
    https://github.com/mwaskom/seaborn/wiki/Frequently-Asked-Questions-(FAQs)#why-cant-i-draw-a-line-over-a-barboxstripviolin-plot – mwaskom May 13 '22 at 10:45

0 Answers0