簡體   English   中英

wxmplot matplotlib wxpython交互式散點圖

[英]wxmplot matplotlib wxpython interactive scatter graph

這是我的代碼

    #!/usr/bin/python
#

import sys
if not hasattr(sys, 'frozen'):
import wxversion
wxversion.ensureMinimal('2.8')

import wxmplot
import numpy
import wx
import os
import subprocess
import re
import wx.lib.plot as plot
import urllib2
from BeautifulSoup import BeautifulSoup
from wx.lib.pubsub import Publisher

""""""

#----------------------------------------------------------------------
def __init__(self, parent, size = (5000,5000)):
    """Constructor"""
    wx.Panel.__init__(self, parent=parent, size = (5000,5000))
    self.frame = parent

    Publisher().subscribe(self.showFrame, ("show.mainframe"))
    menu=wx.MenuBar()
    file0 = wx.Menu()
    help0 = wx.Menu()
    Load=file0.Append(wx.NewId(),"Load Protein","Load from PDB File")
    parent.Bind(wx.EVT_MENU,self.load,Load)
    file0.Append(wx.NewId(),"Save")
    Close = file0.Append(wx.NewId(),"Quit")
    parent.Bind(wx.EVT_MENU,self.close,Close)
    help0.Append(wx.NewId(),"Help")
    help0.Append(wx.NewId(),"About")
    menu.Append(file0,"File")
    menu.Append(help0,"Help")
    parent.SetMenuBar(menu)
    self.pubsubText = wx.StaticText(self,-1," ", (5,150))        


def close(self,event):
    self.Close(True)

def showFrame(self, msg):
    """
    Shows the frame and shows the message sent in the
    text control
    """
    self.pubsubText.SetLabel("This is the Contact Map for the chain "+msg.data[0]+" in the PDB file "+msg.data[1])


self.data = number_list
    x   = numpy.arange(100)/20.0 + numpy.random.random(size=100)
    y   = numpy.random.random(size=len(x))
    def onlasso(data=None, selected=None, mask=None):
        print ':: lasso ', selected
        pframe = wxmplot.PlotFrame()
        pframe.scatterplot(x, y, title='Scatter Plot', size=15,xlabel='$ x\, \mathrm{(\AA)}$',ylabel='$ y\, \mathrm{(\AA^{-1})}$')
        pframe.panel.lasso_callback = onlasso
        pframe.write_message('WXMPlot PlotFrame example: Try Help->Quick Reference')
        pframe.Show()
frame=self.GetParent()
frame.Show()

########################################################################
class MainFrame(wx.Frame):

#----------------------------------------------------------------------
def __init__(self):
    wx.Frame.__init__(self, None, wx.ID_ANY, "PSP Solver")
    panel = MainPanel(self)

#----------------------------------------------------------------------
if __name__ == "__main__":
app = wx.App(False)
frame = MainFrame()
frame.Show()
app.MainLoop()

首先是一幀,帶有菜單欄,然后​​從下拉菜單中選擇“加載蛋白質”,這將使當前幀消失,並彈出一個新幀,然后加載所需的數據,然后按“確定”。 在這之后應該發生的是應該出現一個圖形,但是沒有出現。 我是python的新手,所以不確定我哪里出錯了。 對於該圖,我正在使用wxmplot,我認為它與matplotlib有關。 我認為我的問題是與框架混淆或類似的東西。 任何幫助將不勝感激

通常在將matplotlib與GUI工具包集成時發生這種情況,該問題與matplotlib 后端設置有關。 由於您正在編寫wx應用程序,因此建議您嘗試使用“ WXAgg”或“ WX”后端。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM