1

I'm new to Python programming and I'm currently working as an intern on the topic of Earthquakes, more specifically, amplification of ground shaking due to topographic site effect. My mentor has written a code to extract clusters from a whole lot of amplification curves but the context isn't so important in regards to my problem.

Some of the code is just for plotting the curves, for example:

plt.xlabel('Frequency (Hz)')
plt.ylabel('Amplification')

clr = ["red","black","green","blue","purple","magenta","cyan","orange"]

for n in range(0,nbr):
    tmpd = df[df.cluster==n]
    std = [np.std(tmpd['fq1']),np.std(tmpd['fq2']),np.std(tmpd['fq3']),np.std(tmpd['fq4']),
       np.std(tmpd['fq5']),np.std(tmpd['fq6']),np.std(tmpd['fq7']),np.std(tmpd['fq8']),
       np.std(tmpd['fq9']),np.std(tmpd['fq10']),np.std(tmpd['fq11'])]
    plt.plot(freq,km.cluster_centers_[n,:], color=clr[n])
    plt.plot(freq,km.cluster_centers_[n,:]+std, "r--", color=clr[n])
    plt.plot(freq,km.cluster_centers_[n,:]-std, "r--", color=clr[n])

The plot looks like this:

Here is a screenshot of the code plus error message from Jupyter notebook:

However, everytime there is a piece of the code to plot something I get the following error message (although the plot is still created):

C:\Users\Etudiant\AppData\Local\Temp/ipykernel_30620/944115111.py:12: UserWarning: color is redundantly defined by the 'color' keyword argument and the fmt string "r--" (-> color='r'). The keyword argument will take precedence.
  plt.plot(freq,km.cluster_centers_[n,:]+std, "r--", color=clr[n])

I've tried googling the problem but as a beginner I don't understand the code well enough to fix it. I assume it's sort of a syntax change from one version of Python to another?

S.B
  • 13,077
  • 10
  • 22
  • 49
JulibTulip
  • 23
  • 8

1 Answers1

1

The solution is to delete the r in every 'r--' if there is a color definition after such as:

plt.plot(freq,km.cluster_centers_[n,:]-std, "r--", color=clr[n])
S.B
  • 13,077
  • 10
  • 22
  • 49
JulibTulip
  • 23
  • 8