Error in x, y, and format string must not be None

Asked 2 years ago, Updated 2 years ago, 246 views

I just started Python.

import numpy as np
import matplotlib.pyplot asplt

x = np.linspace(0,2*np.pi,50)
def(x):
    np.sin(x)       
plt.plot(x,f(x),label='y')
plt.show()

where

ValueError: x, y, and format string must not be None

appears.
What does this error mean and what is the cause?

python matplotlib

2022-09-30 14:09

1 Answers

The reason is that the function f(x) has not returned the value (must be return np.sin(x).

In addition, if Python does not explicitly return, the return value of the function is always None, which causes ValueError to display the message must not be None (you must not specify a value of = None).

This post contains comments from @metropolis and @PicoSushi's comment.


2022-09-30 14:09

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.