Ali Ismael نشر 5 نوفمبر 2021 أرسل تقرير نشر 5 نوفمبر 2021 (معدل) كيف يمكننا أن نقوم بحذف subplot من ال Figure؟ تم التعديل في 5 نوفمبر 2021 بواسطة Ali Ismael 1 اقتباس
0 Ali Haidar Ahmad نشر 5 نوفمبر 2021 أرسل تقرير نشر 5 نوفمبر 2021 يمكنك استخدام الدالة fig.delaxes (أو plt.delaxes) حيث نمرر لها ال axes الذي نريد حذفه فقط. انظر للمثال التالي: import matplotlib.pyplot as plt import numpy as np # subplots تعريف fig, ax = plt.subplots() # إنشاء رسم بياني ax.plot([1, 2, 3]) fig.suptitle('matplotlib.figure.Figure.delaxes() \ function Example\n\n', fontweight ="bold") # حذفه #fig.delaxes(ax) plt.show() مثال آخر في حالة كان لديك أكثر من axes: import matplotlib.pyplot as plt import numpy as np # subplots تعريف fig, axs = plt.subplots(1,3) # إنشاء رسم بياني axs[0].plot([1,2],[3,4]) axs[1].plot([5,6],[7,5]) axs[2].plot([0,1],[2,3]) plt.tight_layout() plt.show() والنتيجة ستكون: الآن لحذف ال axes الثاني: import matplotlib.pyplot as plt import numpy as np # subplots تعريف fig, axs = plt.subplots(1,3) # إنشاء رسم بياني axs[0].plot([1,2],[3,4]) axs[1].plot([5,6],[7,5]) axs[2].plot([0,1],[2,3]) # نضيف الدالة ونمرر لها رقمه fig.delaxes(axs[1]) plt.draw() plt.tight_layout() plt.show() النتيجة: اقتباس
السؤال
Ali Ismael
كيف يمكننا أن نقوم بحذف subplot من ال Figure؟
تم التعديل في بواسطة Ali Ismael1 جواب على هذا السؤال
Recommended Posts
انضم إلى النقاش
يمكنك أن تنشر الآن وتسجل لاحقًا. إذا كان لديك حساب، فسجل الدخول الآن لتنشر باسم حسابك.