bugl
bugl
HomeLearnPatternsPathsSearch
HomeLearnPatternsPathsSearch

Loading lesson path

Learn/Python/Data Science and Scientific Python
Python•Data Science and Scientific Python

Matplotlib Markers

Flash cards

Review the key moves

1/4
Core idea

What is the main idea behind Matplotlib Markers?

Lesson checks

Practice each idea before moving on

Short Mimo-style checks built from this lesson's code, terms, and sequence.

1Quick choice

Which statement best captures the main point of this lesson?

2Fill blank

Complete the missing token from the example code.

___ matplotlib.pyplot as plt
3Order

Put the learning moves in the order that makes the concept easiest to apply.

You can also use the shortcut string notation parameter to specify the marker.
You can use the keyword argument marker to emphasize each point with a specified marker:
Format Strings fmt

Markers

You can use the keyword argument marker to emphasize each point with a specified marker:

Example

import matplotlib.pyplot as plt

import numpy as np

ypoints = np.array([3, 8, 1, 10])

plt.plot(ypoints, marker = 'o')

plt.show()

Example

...

plt.plot(ypoints, marker = '*')

...

Format Strings fmt

You can also use the shortcut string notation parameter to specify the marker.

This parameter is also called fmt , and is written with this syntax:

Example

import matplotlib.pyplot as plt

import numpy as np

ypoints = np.array([3, 8, 1, 10])

plt.plot(ypoints, 'o:r')

plt.show()

The marker value can be anything from the Marker Reference above.

The line value can be one of the following:

Marker Size

You can use the keyword argument markersize or the shorter version, ms to set the size of the markers:

Example

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()

Marker Color

You can use the keyword argument markeredgecolor or the shorter mec to set the color of the edge of the markers:

Example

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()

You can use the keyword argument markerfacecolor or the shorter mfc to set the color inside the edge of the markers:

Example

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()

Use both the mec and mfc arguments to color the entire marker:

Example

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()

You can also use Hexadecimal color values :

Example

...

plt.plot(ypoints, marker = 'o', ms = 20, mec = '#4CAF50', mfc = '#4CAF50')

...

Or any of the 140 supported color names .

Example

...

plt.plot(ypoints, marker = 'o', ms = 20, mec = 'hotpink', mfc = 'hotpink')

...

Previous

Machine Learning - Percentiles

Next

Machine Learning - Data Distribution