from matplotlib import pyplot as plt
import numpy as np
%matplotlib notebook
def f_1(x):
return 3/(x-1)
def f_2(x):
return 3/(x+2) - 4
def test(x):
k = -4/3
b = -8/3
return k*x + b
x = np.linspace(-0.99, 0)
plt.plot(x, f_1(x))
plt.plot(x, f_2(x))
plt.plot(x, test(x))
[<matplotlib.lines.Line2D at 0x1c51ab3c3c8>]
x_0 = 1
y_0 = 1
a = 0.5
an = np.linspace(0, 2 * np.pi, 100)
plt.plot(1 * np.cos(an), 1 * np.sin(an))
plt.axvline(x_0 + a)
plt.axvline(x_0 - a)
plt.axhline(y_0 + a)
plt.axhline(y_0 - a)
plt.ylim(-2,2)
plt.xlim(-2,2)
(-2, 2)
from ipywidgets import interactive
import matplotlib.pyplot as plt
import numpy as np
an = np.linspace(0, 2 * np.pi, 100)
plt.plot(1 * np.cos(an), 1 * np.sin(an))
plt.ylim(-2,2)
plt.xlim(-2,2)
def f(x_0, y_0, a):
plt.plot(1 * np.cos(an), 1 * np.sin(an))
plt.axvline(x_0 + a)
plt.axvline(x_0 - a)
plt.axhline(y_0 + a)
plt.axhline(y_0 - a)
plt.ylim(-3,3)
plt.xlim(-3,3)
plt.show()
interactive_plot = interactive(f, x_0=(-2.0, 2.0), y_0=(-3.0, 3.0), a = (0,5.0))
output = interactive_plot.children[-1]
output.layout.height = '350px'
interactive_plot