0

I'm trying to simply make a plot for the equation written below:

import matplotlib.pyplot as plt
import numpy as np

# 100 linearly spaced numbers
x = np.linspace(0,100,100)
y= 1/{np.exp(1/x)+1}

#plot the function
plt.plot(x,y, 'r')

#show the plot
plt.show()

But whenever I use this code, I get the message:

unhashable type: 'numpy.ndarray'

I have searched for the reason for this but the solutions I have seen such as in Python unhashable type: 'numpy.ndarray', doesn't seem to be the same as mine.

How can I correct this and avoid it happening?

1 Answer 1

1

You are using brackets where you should not use it. You need to replace

y= 1/{np.exp(1/x)+1}

by this

y= 1/(np.exp(1/x)+1)
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you so much, I haven't used python in a very long time and seem to have forgotten it all
Happy to help. If this answer or any other one solved your issue, please mark it as accepted.

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.