Guest User

Untitled

a guest
Nov 18th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. import matplotlib
  2. import matplotlib.pyplot as plt
  3. from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
  4. from matplotlib.figure import Figure
  5.  
  6. matplotlib.rcParams.update({'font.size': 8})
  7.  
  8. class Canvas(FigureCanvas):
  9. def __init__(self,parent,dpi=100.0):
  10. size = parent.size()
  11. self.dpi = dpi
  12. self.width = size.width() / dpi
  13. self.height = size.height() / dpi
  14. self.figure = Figure(figsize=(self.width, self.height), dpi=self.dpi, facecolor='w', edgecolor='k', frameon=False)
  15. self.figure.subplots_adjust(left=0.05, bottom=0.05, right=0.95, top=0.95, wspace=None, hspace=None)
  16. self.axes = self.figure.add_subplot(111)
  17. self.axes.axis((-1,1,-1,1))
  18. FigureCanvas.__init__(self, self.figure)
  19. self.updateGeometry()
  20. self.draw()
  21. self.cc = self.copy_from_bbox(self.axes.bbox)
  22. self.particle_plot = None
  23. self.setParent(parent)
  24. self.blit(self.axes.bbox)
  25.  
  26. def on_pre_draw(self):
  27. self.restore_region(self.cc)
  28.  
  29. def on_draw(self):
  30. raise NotImplementedError
  31.  
  32. def on_post_draw(self):
  33. self.blit(self.axes.bbox)
  34.  
  35. def redraw(self):
  36. self.on_pre_draw()
  37. self.on_draw()
  38. self.on_post_draw()
Add Comment
Please, Sign In to add comment