Skip to content

Instantly share code, notes, and snippets.

%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.animation as animation
from IPython.display import HTML
def midpoints(x):
sl = ()
for i in range(x.ndim):
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
%matplotlib widget
import matplotlib.pyplot as plt
from matplotlib import cm
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
#make data
delta = 0.08
x = y = np.arange(-4.0, 4.04, delta)
X, Y = np.meshgrid(x, y)
@sabopy
sabopy / torus_rasen.py
Last active November 8, 2021 10:09
matplotlib torus animation
%matplotlib widget
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from IPython.display import HTML
import numpy as np
from matplotlib import cm
#make data
u=np.linspace(0,2*np.pi,100)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sabopy
sabopy / torus.py
Last active November 5, 2021 13:47
matplotlib torus
from matplotlib import cm
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
u=np.linspace(0,2*np.pi,100)
v=np.linspace(0,2*np.pi,100)
u,v=np.meshgrid(u,v)
a = 2
b = 9
@sabopy
sabopy / swirl_radius_anim.py
Last active October 9, 2021 11:39
swirl_radius変化アニメーション
%matplotlib
import matplotlib.pyplot as plt
from skimage.transform import swirl
import matplotlib.animation as animation
from IPython.display import HTML
#load image
img = plt.imread('kabutomaru.jpg')
#make swirled images
import matplotlib.pyplot as plt
import numpy as np
fig, (ax1, ax2) = plt.subplots(1,2,figsize=(9,4))
ind = np.arange(1,5,1)
ax1.bar(ind,ind, color='m', edgecolor='black', hatch="/")
ax1.bar(ind, np.ones(4) * 4, bottom=ind,
color='c', edgecolor='black', hatch='//')
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sabopy
sabopy / Elliptical_Hough_Transforms.py
Last active March 15, 2021 10:35
楕円によるハフ変換
import matplotlib.pyplot as plt
from skimage import data, color, img_as_ubyte
from skimage.feature import canny
from skimage.transform import hough_ellipse
from skimage.draw import ellipse_perimeter
from skimage.color import rgb2gray,rgba2rgb
# Load picture, convert to grayscale and detect edges