1
Warning (from warnings module):
  File "D:\python\line graph for Compressive Strength.py", line 22
    plt.plot( 'x','y', data=df1, linestyle='-', marker='o',label='AR1154', color='#7f6d5f')
RuntimeWarning: Second argument 'y' is ambiguous: could be a format string but is in 'data'; using as data.  If it was intended as data, set the format string to an empty string to suppress this warning.  If it was intended as a format string, explicitly pass the x-values as well.  Alternatively, rename the entry in 'data'.

How to solve the warning given above?

0

1 Answer 1

1

It appears that your df1 contains columns named 'x' and 'y'. In a sense, the warning objects to you using 'x' and 'y' for column names in your DataFrame. When you passed 'y' as a column name, it thought that maybe you were saying 'y' for yellow, and you wanted a yellow line.

So one solution would be to rename your y column in the data frame to 'y_axis'.

There is an optional 3rd argument to plot -- a format string. Changing your call to this should fix it:

plt.plot('x','y', '', data=df1, linestyle='-', marker='o',label='AR1154', color='#7f6d5f')

This happens because the arguments to plot are defined in a way that makes it impossible to tell whether some arguments are column names or are a format string. I just always throw in a 3rd argument of '' to remove the ambiguity.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.