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)
%matplotlib inline
from ipywidgets import interactive
import matplotlib.pyplot as plt
import numpy as np
import seaborn
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=(-3.0, 3.0), y_0=(-3.0, 3.0), a = (0,5.0))
output = interactive_plot.children[-1]
output.layout.height = '350px'
interactive_plot
Failed to display Jupyter Widget of type interactive
.
If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean that the widgets JavaScript is still loading. If this message persists, it likely means that the widgets JavaScript library is either not installed or not enabled. See the Jupyter Widgets Documentation for setup instructions.
If you're reading this message in another frontend (for example, a static rendering on GitHub or NBViewer), it may mean that your frontend doesn't currently support widgets.