Sublime Forum

Some plots aren't appearing on Sublime text 3 (Python)

#1

I have coded a simple plot without any issue such as:

import matplotlib.pyplot as plt
plt.plot(range(10))
plt.show()

The above plot appears.

The issue comes when I try and plot something like this:

import numpy as np
from scipy.integrate.quadpack import quad
import matplotlib.pyplot as plt

def func(x):
return np.array(x**2)

x = np.linspace(0, 10, 201)
integral, err = quad(func, 1, 5)

print (“The integral is :”), integral
print (“The error is :”), err

section = np.linspace(1, 5, 20)

plt.plot(x, func(x))
plt.fill_between(section, func(section), facecolor=‘red’)

The print statements for the integral and err appear in the console without any issue. Numbers look good. It’s just that the plot isn’t appear. I’m using sublime text 3 with anaconda2.

0 Likes

#2

are you missing a plt.show() call in your second example maybe?

0 Likes