Markers of Matplotlib

Markers in Matplotlib
Markers in Matplotlib

Markers are used in Matplotlib plots to mark the points on a line which refers to a datapoint. All the possible marker styles in Matplotlib are listed here.

However, it is difficult to pick a marker just by looking at its character or its label. I generated the above image as a visual reference to pick markers. It was generated by using this piece of code:

#!/usr/bin/env python
import matplotlib.pyplot as pyplot
mark_dict = {
".":"point",
",":"pixel",
"o":"circle",
"v":"triangle_down",
"^":"triangle_up",
"<":"triangle_left",
">":"triangle_right",
"1":"tri_down",
"2":"tri_up",
"3":"tri_left",
"4":"tri_right",
"8":"octagon",
"s":"square",
"p":"pentagon",
"*":"star",
"h":"hexagon1",
"H":"hexagon2",
"+":"plus",
"D":"diamond",
"d":"thin_diamond",
"|":"vline",
"_":"hline"
}
def line_plot():
x_list = [1, 10, 30, 70]
y_list = [10, 20, 30, 40]
pyplot.clf()
for mark in mark_dict:
y_list = [y_val + 10 for y_val in y_list]
pyplot.plot(x_list, y_list, label=mark_dict[mark], marker=mark)
pyplot.legend(loc="best", prop={'size':11})
pyplot.savefig("markers.png")
def main():
line_plot()
if "__main__" == __name__:
main()

Tried with: Matplotlib 1.3.0 and Ubuntu 12.04 LTS

2 thoughts on “Markers of Matplotlib

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.