【发布时间】:2020-07-22 11:38:57
【问题描述】:
我正在尝试为 Anscombe 数据集创建 2x2 图
加载数据集并分离数据集中的每个类
import seaborn as sns
import matplotlib.pyplot as plt
anscombe = sns.load_dataset('anscombe')
dataset_1 = anscombe[anscombe['dataset'] == 'I']
dataset_2 = anscombe[anscombe['dataset'] == 'II']
dataset_3 = anscombe[anscombe['dataset'] == 'III']
dataset_4 = anscombe[anscombe['dataset'] == 'IV']
创建一个图形并分成 4 个部分
fig = plt.figure()
axes_1 = fig.add_subplot(2,2,1)
axes_2 = fig.add_subplot(2,2,2)
axes_3 = fig.add_subplot(2,2,3)
axes_4 = fig.add_subplot(2,2,4)
axes_1.plot(dataset_1['x'], dataset_1['y'], 'o')
axes_2.plot(dataset_2['x'], dataset_2['y'], 'o')
axes_3.plot(dataset_3['x'], dataset_3['y'], 'o')
axes_4.plot(dataset_4['x'], dataset_4['y'], 'o')
axes_1.set_title('dataset_1')
axes_2.set_title('dataset_2')
axes_3.set_title('dataset_3')
axes_4.set_title('dataset_4')
fig.suptitle('Anscombe Data')
fig.tight_layout()
我在每个地块得到的唯一输出是
[<matplotlib.lines.Line2D at 0x24592c94bc8>]
我做错了什么?
【问题讨论】:
-
此问题不可重现。我可以用你所拥有的来得到你的情节。
conda update conda和conda update --all在 conda 提示符下。此外,在提示符处键入jupyter lab,而不是jupyter notebook。这是较新版本的 jupyter,并且已经是发行版的一部分。 -
好的..我正在尝试。
-
Matplotlib 目前使用的是module://ipykernel.pylab.backend_inline,这是一个非GUI 后端,所以无法显示图。 """启动 IPython 内核的入口点
标签: python matplotlib