اذهب إلى المحتوى
  • 0

استخلاص لون الرسم البياني plot باستخدام Matplotlib في بايثون

Ali Ismael

السؤال

على فرض لدينا الرسم البياني التالي:

import numpy as np
import matplotlib.pyplot as plt
x = range(15)
y = range(15)
p = plt.plot(x,y, x,y*2, x,y*3)

index.png.36516c88dd3927273c01c07f5d814c8f.png
كيف يمكننا معرفة لون كل شكل في الرسم لتخزينه في متغير؟
 

رابط هذا التعليق
شارك على الشبكات الإجتماعية

Recommended Posts

  • 0

يمكنك استخدام الدالة get_color بالشكل التالي:

import numpy as np
import matplotlib.pyplot as plt
x = np.arange(15)
y = np.arange(15)
p = plt.plot(x,y, x,y*2, x,y*3)
print("The color of the first drawing is: "+p[0].get_color()) # لون الشكل الأول
print("The color of the second drawing is: "+p[1].get_color()) # لون الشكل الثاني
print("The color of the third drawing is: "+p[2].get_color()) # الثالث
# الخرج:
"""
The color of the first drawing is: #1f77b4
The color of the second drawing is: #ff7f0e
The color of the third drawing is: #2ca02c
"""

 

رابط هذا التعليق
شارك على الشبكات الإجتماعية

انضم إلى النقاش

يمكنك أن تنشر الآن وتسجل لاحقًا. إذا كان لديك حساب، فسجل الدخول الآن لتنشر باسم حسابك.

زائر
أجب على هذا السؤال...

×   لقد أضفت محتوى بخط أو تنسيق مختلف.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   جرى استعادة المحتوى السابق..   امسح المحرر

×   You cannot paste images directly. Upload or insert images from URL.

  • إعلانات

  • تابعنا على



×
×
  • أضف...