Tkinter 用の Matplotlib でのプロットの更新
Tkinter アプリケーション内で Matplotlib のプロットを更新するときに問題が発生しました。ユーザーがタイム スケール単位を調整できるようにすると、新しいプロットを作成せずにプロットの再計算と更新が必要になります。
アプローチ 1: クリアと再プロット
簡単な方法この方法では、graph1.clear() およびgraph2.clear() を呼び出して既存のプロットをクリアし、データを再プロットします。
アプローチ 2: プロット データの更新
大幅に高速な代替アプローチでは、既存のプロット オブジェクトのデータを更新します。これには、コードを少し調整する必要があります。
def plots(): global vlgaBuffSorted cntr() result = collections.defaultdict(list) for d in vlgaBuffSorted: result[d['event']].append(d) result_list = result.values() f = Figure() graph1 = f.add_subplot(211) graph2 = f.add_subplot(212, sharex=graph1) # Create plot objects vds_line, = graph1.plot([], [], 'bo', label='a') vgs_line, = graph1.plot([], [], 'rp', label='b') isub_line, = graph2.plot([], [], 'b-', label='c') for item in result_list: # Update plot data vds_line.set_data([], []) vgs_line.set_data([], []) isub_line.set_data([], []) tL = [] vgsL = [] vdsL = [] isubL = [] for dict in item: tL.append(dict['time']) vgsL.append(dict['vgs']) vdsL.append(dict['vds']) isubL.append(dict['isub']) # Update plot data vds_line.set_data(tL, vdsL) vgs_line.set_data(tL, vgsL) isub_line.set_data(tL, isubL) # Draw the plot f.canvas.draw() f.canvas.flush_events()
このアプローチでは、プロット オブジェクト (vds_line など) を作成し、反復ごとにそのデータを更新します。 draw() メソッドと flash_events() メソッドは、更新されたプロットを Tkinter ウィンドウに表示するために使用されます。
適切なアプローチを選択することで、Tkinter アプリケーション内の Matplotlib のプロットを効果的に更新できます。
以上が時間スケールを変更した後、Tkinter アプリケーションで Matplotlib プロットを効率的に更新するにはどうすればよいですか?の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

Pythonは解釈された言語ですが、コンパイルプロセスも含まれています。 1)Pythonコードは最初にBytecodeにコンパイルされます。 2)ByteCodeは、Python Virtual Machineによって解釈および実行されます。 3)このハイブリッドメカニズムにより、Pythonは柔軟で効率的になりますが、完全にコンパイルされた言語ほど高速ではありません。

useaforloopwhenteratingoverasequenceor foraspificnumberoftimes; useawhileloopwhentinuninguntinuntilaConditionismet.forloopsareidealforknownownownownownownoptinuptinuptinuptinuptinutionsituations whileoopsuitsituations withinterminedationations。

pythonloopscanleadtoErrorslikeinfiniteloops、ModifiningListsDuringiteration、Off-Oneerrors、Zero-dexingissues、およびNestededLoopinefficiencies.toavoidhese:1)use'i

forloopsareadvastountousforknowterations and sequences、offeringsimplicityandeadability;

pythonusesahybridmodelofcompilation andtertation:1)thepythoninterpretercompilessourcodeodeplatform-indopent bytecode.2)thepythonvirtualmachine(pvm)thenexecuteTesthisbytecode、balancingeaseoputhswithporformance。

pythonisbothintersedand compiled.1)it'scompiledtobytecode forportabalityacrossplatforms.2)bytecodeisthenは解釈され、開発を許可します。

loopsareideal whenyouwhenyouknumberofiterationsinadvance、foreleloopsarebetterforsituationsは、loopsaremoreedilaConditionismetを使用します

henthenumber ofiterationsisknown advanceの場合、dopendonacondition.1)forloopsareideal foriterating over for -for -for -saredaverseversives likelistorarrays.2)whileopsaresupasiable forsaresutable forscenarioswheretheloopcontinupcontinuspificcond


ホットAIツール

Undresser.AI Undress
リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover
写真から衣服を削除するオンライン AI ツール。

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

Video Face Swap
完全無料の AI 顔交換ツールを使用して、あらゆるビデオの顔を簡単に交換できます。

人気の記事

ホットツール

MantisBT
Mantis は、製品の欠陥追跡を支援するために設計された、導入が簡単な Web ベースの欠陥追跡ツールです。 PHP、MySQL、Web サーバーが必要です。デモおよびホスティング サービスをチェックしてください。

EditPlus 中国語クラック版
サイズが小さく、構文の強調表示、コード プロンプト機能はサポートされていません

VSCode Windows 64 ビットのダウンロード
Microsoft によって発売された無料で強力な IDE エディター

ZendStudio 13.5.1 Mac
強力な PHP 統合開発環境

PhpStorm Mac バージョン
最新(2018.2.1)のプロフェッショナル向けPHP統合開発ツール
