Graphs not updating (matplotlib)

I'm trying to make a GUI that contains several figures, each with an axes (is 'axes' plural?). I managed to get the leftmost graph to plot upon initializing the respective widget using this line:

    self.leftImage = self.leftPlot.axes.imshow(self.defaultSlide, cmap = self.mymap)

where self.leftPlot contains the necessary figure properties. I noticed that I didn't have to call plt.show() or its variants for this part, which I don't know whether it's significant or not.

Later in the code, I called self.leftImage.set_data(newSlide) , but nothing seems to change even though it definitely gets executed. I tried setting leftImage to a new instance of imshow() , but that doesn't seem to fix anything.

My imports:

from PySide import QtCore, QtGui
from PySide.QtCore import *
from PySide.QtGui import *
import matplotlib

matplotlib.use('Qt4Agg')
matplotlib.rcParams['backend.qt4']='PySide'

from matplotlib.figure import Figure
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg as NavigationToolbar
import matplotlib.pyplot as plt

I'm fairly new to matplotlib, but I do come from a MATLAB background if that helps.


You should use draw() just after your update (done with set_data() ).

See this related post for detail https://stackoverflow.com/a/17837600/4716013

链接地址: http://www.djcxy.com/p/37908.html

上一篇: 在wx中嵌入透明matplotlib图形画布

下一篇: 图表未更新(matplotlib)