SwadhyAI Notes

All Python notes

Matplotlib Markers 📍

Customizing Points

You can emphasize each point with a specific marker using the marker argument.

✨ Common Markers

'o' Circle
'*' Star
'.' Point
',' Pixel
'x' X
'X' X (filled)
'+' Plus
'P' Plus (filled)
's' Square
'D' Diamond
python
plt.plot(ypoints, marker = 'o')

🎨 Format Strings (fmt)

Use the shortcut notation marker|line|color to define all three quickly.

python
# 'o' = Circle marker
# ':' = Dotted line
# 'r' = Red color
plt.plot(ypoints, 'o:r')

🖌️ Marker Size & Color

Customize the marker appearance further:

  • ms: Marker Size
  • mec: Marker Edge Color
  • mfc: Marker Face Color
python
# 20px size, red edge, hotpink face
plt.plot(ypoints, marker='o', ms=20, mec='r', mfc='hotpink')

💡 Hex Colors

You can use Hexadecimal color values (e.g., #4CAF50) or standard color names (e.g., 'hotpink') for mec and mfc.