我正在将 matplotlib.pyplot 用于我正在开发的一个小模块(附加代码)。但是,我不知道如何自定义图形(增加图形大小,更改背景画布颜色)。我该怎么做呢。我已经尝试过fig = plt.figure(figsize=(16,8))
,self.fig, self.ax = plt.subplots()
这确实增加了图形大小并添加了我的按钮,但在单独的图形上显示了我的情节。我的简单错误是什么?
# Setup the axes.
self.fig, self.ax = plt.subplots()
self.slider_ax = self.fig.add_axes([0.2, 0.03, 0.65, 0.03])
self.delete_ax = self.fig.add_axes([0.85, 0.84, 0.1, 0.04])
self.register_ax = self.fig.add_axes([0.85, 0.78, 0.1, 0.04])
self.add_ax = self.fig.add_axes([0.85, 0.72, 0.1, 0.04])
self.save_ax = self.fig.add_axes([0.85, 0.66, 0.1, 0.04])
self.reset_ax = self.fig.add_axes([0.85, 0.16, 0.1, 0.04])
self.quit_ax = self.fig.add_axes([0.85, 0.1, 0.1, 0.04])
# Make the slider
! self.slider = Slider(self.slider_ax, 'Frame', 0, 1,
valinit=0, valfmt='%1.2f', closedmin=True,
closedmax=False)
self.slider.on_changed(self.update)
#Make the buttons
self.del_button = Button(self.delete_ax, 'Delete')
self.del_button.on_clicked(self.delete)
self.reg_button = Button(self.register_ax, 'Register')
self.reg_button.on_clicked(self.register)
self.add_button = Button(self.add_ax, "Add")
self.add_button.on_clicked(self.add)
self.save_button = Button(self.save_ax, "Save")
self.save_button.on_clicked(self.save)
self.quit_button = Button(self.quit_ax, "Quit")
self.quit_button.on_clicked(self.quit)
self.reset_button = Button(self.reset_ax, "Reset")
self.reset_button.on_clicked(self.reset)
# Plot the first slice of the image
self.im = self.ax.imshow(np.array(raw_dicom_stack[0]), cmap = cm.gray)