Hi, all
I'm play with wxplot lately. But I need to draw a plot only with
axises and labels, no data, and try following code without success. I
just wonder if it is possible to draw a plot without any data?Because
I want to draw the data later.Could anybody tell me how to do it?Any
help would be appreciated!
···
#===========================================
import wx
import wx.lib.plot as plotlib
class myFrame(wx.Frame): ## {{{
def __init__(self, *args, **kwds):
wx.Frame.__init__(self, *args, **kwds)
##------ your widgets
self.canvas_ = plotlib.PlotCanvas(self)
self.draw()
##------ put stuff into sizer
self.sizer_ = wx.BoxSizer(wx.VERTICAL)
self.sizer_.Add(self.canvas_, proportion = 1, flag = wx.EXPAND)
## apply sizer
self.SetSizer(self.sizer_)
self.SetAutoLayout(True)
def draw(self):
self.canvas_.SetFont(wx.Font(10,wx.SWISS,wx.NORMAL,wx.NORMAL))
self.canvas_.SetFontSizeAxis(10)
self.canvas_.SetFontSizeLegend(7)
self.canvas_.SetXSpec('auto')
self.canvas_.SetYSpec('auto')
# data = [(0, 25.1), (1, 30), (2, 40), (3, 50), (4, 25.1), (5,
30), (6, 40), (7, 50)]
# marker = plotlib.PolyMarker(data, legend='', colour='green',
marker='cross',size=1)
# lines = plotlib.PolyLine(data, legend= 'Red Line', colour='red')
# gph = plotlib.PlotGraphics([lines, marker],"Graph Title", "X
Axis", "Y Axis")
gph = plotlib.PlotGraphics([],"Graph Title", "X Axis", "Y Axis")
self.canvas_.Draw(gph, (0, 30), (-10, 40))
## }}}
def main(): ## {{{
app = wx.PySimpleApp(0)
frame = myFrame(None, -1, title = '')
frame.Show(True)
app.SetTopWindow(frame)
app.MainLoop()
## }}}
if __name__ == "__main__":main()