Matplotlib markerlari
Belgilar
Belgilanganmarkerbilan har bir nuqtani ta’kidlash uchunmarkerkalit so‘zidan foydalanishingiz mumkin:
Misol
Har bir nuqtani aylana bilan belgilang:
import matplotlib.pyplot as plt
import numpy as np
ypoints = np.array([3, 8, 1, 10])
plt.plot(ypoints, marker = 'o')
plt.show()
Natija:
Misol
Har bir nuqtani yulduzcha bilan belgilang:
...
plt.plot(ypoints, marker = '*')
...
Natija:
Markerga havola
Siz ushbu belgilardan birini tanlashingiz mumkin:
| Marker | Tavsif | |
|---|---|---|
| 'o' | Circle | Try it » |
| '*' | Star | Try it » |
| '.' | Point | Try it » |
| ',' | Pixel | Try it » |
| 'x' | X | Try it » |
| 'X' | X (filled) | Try it » |
| '+' | Plus | Try it » |
| 'P' | Plus (filled) | Try it » |
| 's' | Square | Try it » |
| 'D' | Diamond | Try it » |
| 'd' | Diamond (thin) | Try it » |
| 'p' | Pentagon | Try it » |
| 'H' | Hexagon | Try it » |
| 'h' | Hexagon | Try it » |
| 'v' | Triangle Down | Try it » |
| '^' | Triangle Up | Try it » |
| '<' | Triangle Left | Try it » |
| '>' | Triangle Right | Try it » |
| '1' | Tri Down | Try it » |
| '2' | Tri Up | Try it » |
| '3' | Tri Left | Try it » |
| '4' | Tri Right | Try it » |
| '|' | Vline | Try it » |
| '_' | Hline | Try it » |
Format stringlari fmt
Markerni ko‘rsatish uchun qisqartirilgan format stringi (shortcut string notation) parametridan ham foydalanishingiz mumkin.
Ushbu parametrfmtdeb ham ataladi va bu sintaksis bilan yoziladi:
marker|line|color
Misol
Har bir nuqtani aylana bilan belgilang:
import matplotlib.pyplot as plt
import numpy as np
ypoints = np.array([3, 8, 1, 10])
plt.plot(ypoints, 'o:r')
plt.show()
Natija:
Marker qiymati yuqoridagi Marker ma’lumotnomasidan istalgan narsa bo‘lishi mumkin.
Chiziq qiymati quyidagilardan biri bo‘lishi mumkin:
Chiziqli havola
| Line Syntax | Tavsif | |
|---|---|---|
| '-' | Solid line | Try it » |
| ':' | Dotted line | Try it » |
| '--' | Dashed line | Try it » |
| '-.' | Dashed/dotted line | Try it » |
Eslatma: Agar fmt parametrida chiziq qiymatini qoldirsangiz, hech qanday chiziq chizilmaydi.
Qisqa rang qiymati quyidagilardan biri bo‘lishi mumkin:
Rang ma’lumotnomasi
| Color Syntax | Tavsif | |
|---|---|---|
| 'r' | Red | Try it » |
| 'g' | Green | Try it » |
| 'b' | Blue | Try it » |
| 'c' | Cyan | Try it » |
| 'm' | Magenta | Try it » |
| 'y' | Yellow | Try it » |
| 'k' | Black | Try it » |
| 'w' | White | Try it » |
Marker hajmi
Markerlar hajmini belgilash uchun siz markersize kalit so‘z argumentidan yoki qisqaroq versiyamsdan foydalanishingiz mumkin:
Misol
Markerlarning o‘lchamini 20 ga o‘rnating:
import matplotlib.pyplot as plt
import numpy as np
ypoints = np.array([3, 8, 1, 10])
plt.plot(ypoints, marker = 'o', ms = 20)
plt.show()
Natija:
Marker rangi
Markerlar chetining rangini o‘rnatish uchun siz markeredgecolor kalit so‘z argumentidan yoki qisqaroqmecdan foydalanishingiz mumkin:
Misol
EDGE rangini qizil rangga o‘rnating:
import matplotlib.pyplot as plt
import numpy as np
ypoints = np.array([3, 8, 1, 10])
plt.plot(ypoints, marker = 'o', ms = 20, mec = 'r')
plt.show()
Natija:
Markerlar chetidagi rangni o‘rnatish uchun siz markerfacecolor kalit so‘z argumentidan yoki qisqaroqmfcdan foydalanishingiz mumkin:
Misol
YUZ rangini qizil rangga o‘rnating:
import matplotlib.pyplot as plt
import numpy as np
ypoints = np.array([3, 8, 1, 10])
plt.plot(ypoints, marker = 'o', ms = 20, mfc = 'r')
plt.show()
Natija:
Butun markerni ranglash uchunmecvamfcargumentlaridan foydalaning:
Misol
Chet va yuzning rangini qizil rangga o‘rnating:
import matplotlib.pyplot as plt
import numpy as np
ypoints = np.array([3, 8, 1, 10])
plt.plot(ypoints, marker = 'o', ms = 20, mec = 'r', mfc = 'r')
plt.show()
Natija:
O‘n oltilik rang qiymatlaridan ham foydalanishingiz mumkin:
Misol
Har bir nuqtani chiroyli yashil rang bilan belgilang:
...
plt.plot(ypoints, marker = 'o', ms = 20, mec = '#4CAF50', mfc = '#4CAF50')
...
Natija:
Yoki qo‘llab-quvvatlanadigan 140 ta rang nomlaridan birortasi.
Misol
Har bir nuqtani "hotpink" deb nomlangan rang bilan belgilang:
...
plt.plot(ypoints, marker = 'o', ms = 20, mec = 'hotpink', mfc = 'hotpink')
...
Natija:
W3Schools Pathfinder
Yutuqlaringizni kuzating – bu bepul!
