jupyter notebook中matplotlib inline 关闭或打开

it2023-04-03  75

import matplotlib.pyplot as plt import numpy as np import mplcursors np.random.seed(42)

inline 打开

%matplotlib inline plt.scatter(*np.random.random((2, 26))) crs = mplcursors.cursor(hover=True) crs.connect("add", lambda sel: sel.annotation.set_text( 'Point {},{}'.format(sel.target[0], sel.target[1]))) plt.show()

inline 关闭(跳出可交互的plot)

%matplotlib auto plt.scatter(*np.random.random((2, 26))) crs = mplcursors.cursor(hover=True) crs.connect("add", lambda sel: sel.annotation.set_text( 'Point {},{}'.format(sel.target[0], sel.target[1]))) plt.show() plt.ion()
最新回复(0)