How to plotting line graph with different linestyle using matplotlib

660 Views Asked by At

I have data of minimum ping time in normal condition and in DOS simulation so the data will be different. I still newbie as data scientist and only can make visualization from the data like this.

enter image description here

The code to build the picture above is this

fig, ax = plt.subplots(figsize=(15,8), dpi=300)
df_min.plot(kind='line', 
            x='no', 
            y=['min1','min2'], 
            color=['blue','red'],
            ax=ax)
plt.xlabel('Attempt amount')
plt.ylabel('Min')
plt.title('Comparison of Min Value')
plt.legend(['Normal','Syn Flood'])

Is anyone know how to change the linestyle, I mean the blue is still using this '-' but the red can changed become '--' or 'x'?

I was trying to inject the df_min.plot withlinestyle=['-','--']

But got error, is anybody have idea?

I will upload the data into my drive, so you can download it, here is the link

Thanks!

1

There are 1 best solutions below

1
banikr On
df_min = pd.read_csv(csvpath)
fig, ax = plt.subplots(figsize=(15,8), dpi=300)
df_min.plot(kind='line',  #'line', 
            style='-.',
            x='no', 
            y=['min1','min2'], 
            color=['blue','red'],
            ax=ax)
plt.xlabel('Attempt amount')
plt.ylabel('Min')
plt.title('Comparison of Min Value')
plt.legend(['Normal','Syn Flood'])

Try running this.