Exemple #1
0
class MainView(ZApplicationView):
  # Constructor
  def __init__(self, title, x, y, width, height):
    super(MainView, self).__init__(title, x, y, width, height)
    
    self.plotter = ZScrolledPlottingArea(self, 1200, 500)
    
    self.ax1= self.plotter.add(131)
    self.ax1.hist(rand(100), bins=20, color='k', alpha=0.3)
    
    self.ax2= self.plotter.add(132)
    self.ax2.scatter(np.arange(30), np.arange(30) + 3 * rand(30))

    self.ax3 = self.plotter.add(133)
    
    sns.set()
    uniform_data = np.random.rand(100, 100)
    sns.heatmap(uniform_data, ax = self.ax3)

    self.add(self.plotter)
    
    self.show()

  def file_save(self):
    try:
      abs_current_path = os.path.abspath(os.path.curdir)
      files_types = "PDF (*.pdf);;PGF (*.pgf);;PNG (*.png);;PS (*.ps);;EPS (*.eps);;RAW (*.raw);;RGBA (*.rgba);;SVG (*.svg);;SVGZ (*.svgz)"
      filename, _ = QFileDialog.getSaveFileName(self, "FileSaveDialog", 
                             os.path.join(abs_current_path, "figure.png"),
                             files_types)
      if filename:
        plt.savefig(filename) 
    except:
      traceback.print_exc()
Exemple #2
0
class MainView(ZApplicationView):
  def __init__(self, title, x, y, width, height):
    super(MainView, self).__init__(title, x, y, width, height)
    
    self.plotter = ZScrolledPlottingArea(self, 800, 600)
  
    self.ax= self.plotter.add(111)

    sns.set()
    dataset3 = pd.read_csv("http://pythondatascience.plavox.info/wp-content/uploads/2016/05/sample_dataset.csv")
    dataset3 = dataset3.pivot("Sex", "Occupation", "Salary")
    sns.heatmap(dataset3, cmap="jet", ax = self.ax)

    self.add(self.plotter)
    
    self.show()

  def file_save(self):
    try:
      abs_current_path = os.path.abspath(os.path.curdir)
      files_types = "All Files (*);;Image Files (*.png;*jpg;*.jpeg)"
      filename, _ = QFileDialog.getSaveFileName(self, "FileSaveDialog", 
                             os.path.join(abs_current_path, "image.png"),
                             file_types)
      if filename:
        self.image_view.file_save(filename)
         
    except:
      traceback.print_exc()
class MainView(ZApplicationView):
  def __init__(self, title, x, y, width, height):
    super(MainView, self).__init__(title, x, y, width, height)
    
    self.plotter = ZScrolledPlottingArea(self, 800, 600)
  
    self.ax= self.plotter.add(111)

    sns.set()
    flights = sns.load_dataset("flights")
 
    flights = flights.pivot("month", "year", "passengers")
 
    sns.heatmap(flights, annot=True, fmt="d", ax = self.ax)
    
    self.add(self.plotter)
    
    self.show()

  def file_save(self):
    try:
      abs_current_path = os.path.abspath(os.path.curdir)
      files_types = "PDF (*.pdf);;PGF (*.pgf);;PNG (*.png);;PS (*.ps);;EPS (*.eps);;RAW (*.raw);;RGBA (*.rgba);;SVG (*.svg);;SVGZ (*.svgz)"
      filename, _ = QFileDialog.getSaveFileName(self, "FileSaveDialog", 
                             os.path.join(abs_current_path, "figure.png"),
                             files_types)
      if filename:
        plt.savefig(filename) 
    except:
      traceback.print_exc()