hamda
hamda

Reputation: 1

'float' object cannot be interpreted as an integer for array

this is the code I have below

import matplotlib.pyplot as plt
import numpy as np
fig, ax1 = plt.subplots()
z = np.linspace(0.20, 0.30, 0.01)

and the error I get TypeError: 'float' object cannot be interpreted as an integer how to fix this

Upvotes: 0

Views: 824

Answers (2)

Ali_Sh
Ali_Sh

Reputation: 2816

As it is explained in the NumPy documentation, number of samples between the two limits must be specified, not the increments. i.e. the code must be as:

z = np.linspace(0.20, 0.30, num=11)

Upvotes: 1

ahmedrajput
ahmedrajput

Reputation: 28

The last argument of the np.linspace function is the count of elements to be generated which should be an integer and not a float value.

Upvotes: 0

Related Questions