小编Bru*_*nho的帖子

如何将 ipywidget 滑块的默认位置更改为 matplotlib 图形的一侧?

我正在寻找一种方法来更改 matplotlib 图右侧的垂直 IntSlider 的位置。这是代码:

from ipywidgets import interact, fixed, IntSlider
import numpy as np
from matplotlib import pyplot as plt

%matplotlib notebook

fig = plt.figure(figsize=(8,4))

xs = np.random.random_integers(0, 5000, 50)
ys = np.random.random_integers(0, 5000, 50)

ax = fig.add_subplot(111)
scat, = ax.plot(xs, ys, 'kx', markersize=1)
ax.grid(which='both', color='.25', lw=.1)
ax.set_aspect('equal'), ax.set_title('Rotate')

def rotate(theta, xs, ys):
    new_xs = xs * np.cos(np.deg2rad(theta)) - ys * np.sin(np.deg2rad(theta))
    new_xs -= new_xs.min()
    new_ys = xs * np.sin(np.deg2rad(theta)) + ys * np.cos(np.deg2rad(theta))
    new_ys -= new_ys.min()
    return new_xs, …
Run Code Online (Sandbox Code Playgroud)

python matplotlib jupyter ipywidgets

5
推荐指数
1
解决办法
6863
查看次数

标签 统计

ipywidgets ×1

jupyter ×1

matplotlib ×1

python ×1