Ali Ismael نشر 2 نوفمبر 2021 أرسل تقرير مشاركة نشر 2 نوفمبر 2021 أريد طريقة لتغيير ألوان المحاور في Matplotlib، على سبيل المثال في الكود التالي: import numpy as np import matplotlib.pyplot as plt x = np.linspace(-2, 2, 50) y1 = x**3 y2 = x**2 fig, ax = plt.subplots() ax.plot(x, y1, c = 'black',label = 'x^3') ax.plot(x, y2, c = 'c',label = 'x^2') leg = plt.legend(title="your_title") plt.show() 1 اقتباس رابط هذا التعليق شارك على الشبكات الإجتماعية More sharing options...
0 Ali Haidar Ahmad نشر 2 نوفمبر 2021 أرسل تقرير مشاركة نشر 2 نوفمبر 2021 (معدل) يمكنك القيام بتغييرها بالشكل التالي: ax.spines['right'].set_color('color') ax.spines['left'].set_color('color') ax.spines['bottom'].set_color('color') ax.spines['top'].set_color('color') وبالتالي يكون الكود: import numpy as np import matplotlib.pyplot as plt x = np.linspace(-2, 2, 50) y1 = x**3 y2 = x**2 fig, ax = plt.subplots() ax.plot(x, y1, c = 'black',label = 'x^3') ax.plot(x, y2, c = 'c',label = 'x^2') leg = plt.legend(title="your_title") ax.spines['bottom'].set_color('blue') ax.spines['top'].set_color('y') ax.spines['right'].set_color('red') ax.spines['left'].set_color('red') plt.show() والنتيجة: كذلك يمكنك تغيير ألوان العلامات ticks من خلال: ax.tick_params(axis='x', colors='red') ax.tick_params(axis='y', colors='red') أو التسميات label: ax.yaxis.label.set_color('red') ax.xaxis.label.set_color('red') أو العنوان title: ax.title.set_color('red') تم التعديل في 2 نوفمبر 2021 بواسطة Ali Haidar Ahmad اقتباس رابط هذا التعليق شارك على الشبكات الإجتماعية More sharing options...
السؤال
Ali Ismael
أريد طريقة لتغيير ألوان المحاور في Matplotlib، على سبيل المثال في الكود التالي:
رابط هذا التعليق
شارك على الشبكات الإجتماعية
1 جواب على هذا السؤال
Recommended Posts
انضم إلى النقاش
يمكنك أن تنشر الآن وتسجل لاحقًا. إذا كان لديك حساب، فسجل الدخول الآن لتنشر باسم حسابك.