AxesSubPlot オブジェクトの独立した作成は可能ですか?
matplotlib ドキュメントが示唆しているように、Figure 内での AxesSubPlot インスタンスの作成は通常、Figure を通じて行われます。 add_subplot。ただし、これらのオブジェクトを Figure とは独立して作成し、複数の Figure で再利用できるようにすることが望ましい場合があります。
異なる Figure での AxesSubPlots の再利用
できないにもかかわらずFigure から軸の作成を完全に切り離すために、以前に作成した軸を新規または既存の Figure で再利用できます。これは、単純な関数で実現できます。
def plot_axes(ax, fig=None, geometry=(1, 1, 1)): if fig is None: fig = plt.figure() if ax.get_geometry() != geometry: ax.change_geometry(*geometry) ax = fig.axes.append(ax) return fig
この関数は、既存の軸インスタンス ax を取得し、オプションでそれを新規または既存の Figure fig に追加し、指定されたジオメトリ (行、列、
使用例
この機能を実証するには、次のことを考慮してください。コード:
import numpy as np import matplotlib.pyplot as plt x = np.linspace(0, 6 * np.pi, 100) # Create axes subplots independently ax1 = plt.axes() ax2 = plt.axes() # Add ax1 to figure 1 fig1 = plt.figure() plt.axes.append(ax1) # Add ax2 to figure 2 fig2 = plt.figure() plt.axes.append(ax2) # Plot data on ax1 ax1.plot(x, np.sin(x)) ax1.set_ylabel("Sin(x)") # Plot data on ax2 ax2.plot(x, np.cos(x)) ax2.set_ylabel("Cos(x)") plt.show()
この例では、2 つの軸のサブプロットが独立して作成され、2 つの別々の Figure に追加されます。各サブプロットには独自のデータとラベルが含まれます。
以上がAxesSubPlot オブジェクトは Matplotlib の Figure とは独立して作成できますか?の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

forhandlinglaredataSetsinpython、usenumpyArrays forbetterperformance.1)numpyarraysarememory-effictientandfasterfornumericaloperations.2)nusinnnnedarytypeconversions.3)レバレッジベクトル化は、測定済みのマネージメーシェイメージーウェイズデイタイです

inpython、listsusedynamicmemoryallocation with allocation、whilenumpyArraysalocatefixedmemory.1)listsallocatemorememorythanneededededinitivative.2)numpyArrayasallocateexactmemoryforements、rededicablebutlessflexibilityを提供します。

inpython、youcanspecthedatatypeyfelemeremodelernspant.1)usenpynernrump.1)usenpynerp.dloatp.ploatm64、フォーマーpreciscontrolatatypes。

numpyisessentialfornumericalcomputinginpythonduetoitsspeed、memory efficiency、andcomprehensivematicalfunctions.1)それは、performsoperations.2)numpyArraysaremoremory-efficientthanpythonlists.3)Itofderangeofmathematicaloperty

contiguousMemoryAllocationisucial forArraysは、ForeffienceAndfastelementAccess.1)iteenablesConstantTimeAccess、O(1)、DuetodirectAddresscalculation.2)itemprovesefficiencyByAllowingMultiblementFechesperCacheLine.3)itimplifieMememm

slicingapythonlistisdoneusingtheyntaxlist [start:stop:step] .hore'showitworks:1)startisthe indexofthefirstelementtoinclude.2)spotisthe indexofthefirmenttoeexclude.3)staptistheincrementbetbetinelements

numpyallows forvariousoperationsonarrays:1)basicarithmeticlikeaddition、減算、乗算、および分割; 2)AdvancedperationssuchasmatrixMultiplication;

Arraysinpython、特にnumpyandpandas、aresentialfordataanalysis、offeringspeedandeficiency.1)numpyarraysenable numpyarraysenable handling forlaredatasents andcomplexoperationslikemoverages.2)Pandasextendsnumpy'scapabivitieswithdataframesfortruc


ホットAIツール

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

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

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

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

人気の記事

ホットツール

AtomエディタMac版ダウンロード
最も人気のあるオープンソースエディター

MinGW - Minimalist GNU for Windows
このプロジェクトは osdn.net/projects/mingw に移行中です。引き続きそこでフォローしていただけます。 MinGW: GNU Compiler Collection (GCC) のネイティブ Windows ポートであり、ネイティブ Windows アプリケーションを構築するための自由に配布可能なインポート ライブラリとヘッダー ファイルであり、C99 機能をサポートする MSVC ランタイムの拡張機能が含まれています。すべての MinGW ソフトウェアは 64 ビット Windows プラットフォームで実行できます。

ゼンドスタジオ 13.0.1
強力な PHP 統合開発環境

SublimeText3 中国語版
中国語版、とても使いやすい

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

ホットトピック









