前の投稿分に日本語でタイトル追加。
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Used to guarantee to use at least Wx2.8
import wxversion
wxversion.ensureMinimal('2.8')
import wx
import wx.aui
import matplotlib
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg
from matplotlib.backends.backend_wxagg import NavigationToolbar2Wx
import matplotlib.font_manager as fm
class Plot(wx.Panel):
def __init__(self, parent, id = -1, dpi = None, **kwargs):
wx.Panel.__init__(self, parent, id=id, **kwargs)
self.figure = matplotlib.figure.Figure(dpi=dpi, figsize=(2,2))
self.canvas = FigureCanvasWxAgg(self, -1, self.figure)
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(self.canvas, 1, wx.EXPAND)
self.SetSizer(sizer)
def get_figure(self):
return self.figure
def demo():
app = wx.PySimpleApp()
frame = wx.Frame(None, -1, 'Plotter')
plot = Plot(frame)
sizer = wx.BoxSizer()
sizer.Add(plot, 1, wx.EXPAND)
frame.SetSizer(sizer)
axes = plot.get_figure().gca()
axes.plot([1, 2, 3, 4, ],[2, 1, 4, 1, ])
prop = fm.FontProperties(fname='/usr/share/fonts/opentype/ipafont/ipag.ttf')
plot.get_figure().gca(kwargs='title').set_title(u'グラフだぴょーん', size='24', fontproperties=prop)
frame.Show()
app.MainLoop()
if __name__ == "__main__":
demo()
0 件のコメント:
コメントを投稿