#!/usr/bin/env python # coding: utf-8 # In[1]: from matplotlib import pyplot as plt import numpy as np get_ipython().run_line_magic('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)) # In[12]: 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) # In[7]: get_ipython().run_line_magic('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