bibscy
bibscy

Reputation: 2718

How to draw a line on a plot?

I am trying to draw a line on a plit, but the plot is not even showing. I have checked the values of xPoints and yPoints and they exist.
What is the cause?

import matplotlib.pyplot as plt
import numpy as np

def calculateFuncFor(x):
    ePower = np.e**np.exp(x)
    result = 1 - ePower
    
    return "{:.4f}".format(result) #format the result


xPoints = np.linspace(0,1) #outputs 50 points between 0 and 1 
yPoints = np.zeros(len(xPoints)) #fill a list with 50 zeros


for i in range(len(xPoints)):
    yPoints[i] = calculateFuncFor(xPoints[i])

plt.plot(xPoints, yPoints,'ro')
plt.show()

Upvotes: 0

Views: 38

Answers (1)

vvvvv
vvvvv

Reputation: 31800

Try putting in the first cell of your Jupyter Notebook the following:

%matplotlib inline

% denotes the IPython magic built-in commands

Upvotes: 1

Related Questions