複数の Matplotlib サブプロットの統合凡例の作成
Matplotlib を使用して複数のサブプロットのデータを視覚化する場合、単一の凡例を表示することが望ましい場合があります。すべてのサブプロットに適用される包括的な凡例。データ値が異なっていても、サブプロットは同じ行ラベルを共有できます。
解決策:
get_legend_handles_labels() 関数を利用して、すべてのサブプロットから凡例ラベルを収集できます。 :
<code class="python">handles, labels = ax.get_legend_handles_labels()</code>
ここで、ax はグリッド内の最後のサブプロットの軸オブジェクトを表します。
単一の凡例を表示するには、以下を呼び出します:
<code class="python">fig.legend(handles, labels, loc='upper center')</code>
Pyplot インターフェイス:
pyplot インターフェイスを使用する場合は、次のコマンドを使用して凡例要素を取得します:
<code class="python">handles, labels = plt.gca().get_legend_handles_labels()</code>
追加メモ:
- サブプロットの凡例の削除については、「matplotlib Figure の凡例を削除する」を参照してください。
- X 軸を共有するサブプロット全体で凡例をマージするには、「Twinx() による二次軸: 凡例に追加する方法」を参照してください。
以上が複数の Matplotlib サブプロットの統合凡例を作成するにはどうすればよいですか?の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

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

pythonisnotpurelyLepted; itusesahybridapproachofbytecodecodecodecodecodecodedruntimerttation.1)pythoncompilessourcodeintobytecode、whodythepythonvirtualmachine(pvm).2)

ToconcatenateListsinpythothesheElements、使用:1)Operatortokeepduplicates、2)asettoremoveduplicates、or3)listcomplunting for controloverduplicates、各メトドハスディフェルフェルフェントパフォーマンスアンドソーダーインプリテーション。

pythonisantertedlanguage、useaseofuseandflexibility-butfactingporformantationationsincriticalapplications.1)解釈されたlikepythonexecuteline-by-lineを解釈します

Useforloopswhenthenumberofiterationsisknowninadvance、andwhiloopswheniterationsdependonacondition.1)forloopsareidealforsecenceslikelistoranges.2)


ホットAIツール

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

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

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

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

人気の記事

ホットツール

SublimeText3 英語版
推奨: Win バージョン、コードプロンプトをサポート!

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

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

Safe Exam Browser
Safe Exam Browser は、オンライン試験を安全に受験するための安全なブラウザ環境です。このソフトウェアは、あらゆるコンピュータを安全なワークステーションに変えます。あらゆるユーティリティへのアクセスを制御し、学生が無許可のリソースを使用するのを防ぎます。

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