<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def undobutton_action(self):
 """ when undo is clicked, revert the thematic map to the previous state"""

        if len(self.history) > 1:
            old = self.history.pop(-1)
            self.selection_array = old
            self.mask.set_data(old)
            self.fig.canvas.draw_idle()