Matplotlib での不連続軸の作成
Matplotlib では、X 軸の外観を変更して、2 つの値の範囲間の不連続性を示すことができます。
軸のカスタマイズ
不連続な軸を直接作成する方法と同様に、軸のラベルと外観をカスタマイズすることで同様の効果を実現できます。 1 つの方法は、カスタム変換を使用して不連続な軸を作成することです。
サブプロット
カスタム変換を作成したくない場合は、サブプロットを使用して目的の効果を実現できます。 X 軸の範囲が異なる 2 つのサブプロットを作成し、それらの間のスパインを非表示にすることで、不連続な軸をシミュレートできます。
例
import matplotlib.pyplot as plt import numpy as np x = np.r_[0:1:0.1, 9:10:0.1] y = np.sin(x) fig, (ax, ax2) = plt.subplots(1, 2, sharey=True) ax.plot(x, y, 'bo') ax2.plot(x, y, 'bo') ax.set_xlim(0, 1) ax2.set_xlim(9, 10) ax.spines['right'].set_visible(False) ax2.spines['left'].set_visible(False) ax.yaxis.tick_left() ax2.yaxis.tick_right() plt.subplots_adjust(wspace=0.15) plt.show()
このコードは、それぞれ 2 つのサブプロットを持つプロットを作成します。異なる範囲の X 値を示しています。サブプロット間の重なりは、不連続な軸の外観を作成するために非表示になります。
破断効果
破断した軸線 (//) 効果を追加するには、次のコードを使用できます。
ax.plot((1-d,1+d),(-d,+d), **kwargs) # top-left diagonal ax.plot((1-d,1+d),(1-d,1+d), **kwargs) # bottom-left diagonal kwargs.update(transform=ax2.transAxes) # switch to the bottom axes ax2.plot((-d,d),(-d,+d), **kwargs) # top-right diagonal ax2.plot((-d,d),(1-d,1+d), **kwargs) # bottom-right diagonal
ここで、d は座標軸の対角線のサイズを表します。このコードは、各軸の角に対角線を追加し、壊れた軸の印象を与えます。
以上がMatplotlib で不連続な X 軸を作成するには?の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

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

listsandnumpyarraysinpythonhavedifferentmemoryfootprints:listsaremoreflexiblellessmemory-efficient、whileenumpyarraysaraysareoptimizedfornumericaldata.1)listsstorereferencesto objects、with whowedaround64byteson64-bitedatigu

toensurepythonscriptsbehaveCorrectlyAcrossDevelosment、staging、and Production、usetheseStrategies:1)環境variablesforsimplestetings、2)configurationfilesforcomplexsetups、and3)dynamicloadingforadaptability.eachtododododododofersuniquebentandrequiresca

Pythonリストスライスの基本的な構文はリストです[start:stop:step]。 1.STARTは最初の要素インデックス、2。ストップは除外された最初の要素インデックスであり、3.ステップは要素間のステップサイズを決定します。スライスは、データを抽出するためだけでなく、リストを変更および反転させるためにも使用されます。

ListSoutPerformArraysIn:1)ダイナミシジョンアンドフレーケンティオン/削除、2)ストーリングヘテロゼンダタ、および3)メモリ効率の装飾、ButmayhaveslightPerformancostsinceNASOPERATIONS。

toconvertapythonarraytoalist、usetheList()constructororageneratorexpression.1)importhearraymoduleandcreateanarray.2)useList(arr)または[xforxinarr] toconvertoalistは、largedatatessを変えることを伴うものです。


ホットAIツール

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

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

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

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

人気の記事

ホットツール

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

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

ドリームウィーバー CS6
ビジュアル Web 開発ツール

Dreamweaver Mac版
ビジュアル Web 開発ツール

SublimeText3 Linux 新バージョン
SublimeText3 Linux 最新バージョン

ホットトピック









