0

I am trying to make a connected scatter plot. I was able to make this simple plot, but I want to add a line between the points within each group. I tried the linestyle argument (in below code), but this did not connect the dots. How can I add this line?

fig, ax = plt.subplots()

colors = {'RMSE':'red', 'MAE':'green', 'R2':'blue'}

grouped = metrics_df.groupby('metric')
for key, group in grouped:
    group.plot(ax=ax, kind='scatter', x='num_features', y='score', label=key, color=colors[key], linestyle='solid')

plt.show()

enter image description here

JVDeasyas123
  • 263
  • 3
  • 14

2 Answers2

0

You can try

linestyle='-'

and see if that works

Marcus Cazzola
  • 313
  • 1
  • 9
0

you have to specify arguments like :

linestyle='--', marker='o'

as specified in the first answer of this question Set markers for individual points on a line in Matplotlib

AdForte
  • 305
  • 2
  • 12