Upgrade to Pro — share decks privately, control downloads, hide ads and more …

tkinter(pySimpleGUI)でmatplotlibなしでグラフを書く方法

Jun okazaki
October 10, 2019

 tkinter(pySimpleGUI)でmatplotlibなしでグラフを書く方法

Jun okazaki

October 10, 2019
Tweet

More Decks by Jun okazaki

Other Decks in Technology

Transcript

  1. PySimpleGUIでグラフを書く • DrawCircle • DrawLine • DrawPoint • DrawRectangle •

    DrawOval • DrawImage https://pysimplegui.readthedocs.io/en/latest/#graph-element
  2. 棒グラフ graph.DrawRectangle(top_left=(i * BAR_SPACING + EDGE_OFFSET, graph_infos[i][1]['accepted']), bottom_right=(i * BAR_SPACING

    + EDGE_OFFSET + BAR_WIDTH, 0), fill_color='blue’) graph.DrawText(text=graph_infos[i][1][‘accepted’], location=(i*BAR_SPACING+EDGE_OFFSET+2, graph_infos[i][1]['accepted']+10)) # 値を表⽰ graph.DrawText(text=graph_infos[i][1]['title'], location=(i*BAR_SPACING+EDGE_OFFSET+25, -10))
  3. 折れ線グラフ graph.DrawText(text=graph_infos[i][1]['accepted'], location=(i*BAR_SPACING+EDGE_OFFSET+2, graph_infos[i][1]['accepted']+10)) # 値を表⽰ graph.DrawText(text=graph_infos[i][1]['title'], location=(i*BAR_SPACING+EDGE_OFFSET+25, -10)) if

    i > 0: graph.DrawLine(((i-1) * BAR_SPACING + EDGE_OFFSET+ BAR_WIDTH/2 , graph_infos[(i-1)][1]['accepted']) , (i * BAR_SPACING + EDGE_OFFSET+ BAR_WIDTH/2 , graph_infos[i][1]['accepted']),color='blue', width=1 ) graph.DrawPoint((i * BAR_SPACING + EDGE_OFFSET+ BAR_WIDTH/2 ,graph_infos[i][1]['accepted']), size=3 ,color='blue',) # 値を表⽰
  4. まとめ • TODO • グラフの種類(折れ線/棒グラフ)の切り替え • 累積もしたい • ボタンで複数のグラフを同時に表⽰する •

    範囲指定(数字を⼊⼒)で表⽰する範囲を変える • マウスでドラッグして表⽰範囲を変える • 続き(TODO実装)はQittaに書く予定