Question
What are some reasons to apply linestyles and markers on a graph?
Answer
Generally, linestyles and markers are applied to make the lines on a graph easier to understand, and to mark specific points on the graph clearly.
For example, say that we wanted to see the growth of a stock price over time, but also wanted to see its value for the first day of each month clearly. By using markers on a line, we can see both the progression of the price over time, and also see the precise points for the prices each first day of each month. In a way, the line part lets us see the overall progression of x vs y, while markers let us see precise values at specific points, like checkpoints.
Linestyles and markers are especially helpful to apply when you start to have many lines plotted on the same graph, because it may become harder to distinguish them.
Furthermore, line styles and markers are not absolutely necessary all the time, but including them can make a graph easier to understand and give it a more professional feeling. Do what works for you!
2 Likes
How to show integer on axes? I have added “int” before months, but it didn’t show in the result
plt.subplot(1, 2, 1)
plt.plot(int(months), temperature)
plt.subplot(1, 2, 2)
plt.plot(temperature, flights_to_hawaii, "o")
plt.show()
I was confused with Marker but you have not only explained but also the difference between Linestyle and Markers.
2 Likes
Different types of Markers and their Keywords
marker symbol description
"." m00 point
"," m01 pixel
"o" m02 circle
"v" m03 triangle_down
"^" m04 triangle_up
"<" m05 triangle_left
">" m06 triangle_right
"1" m07 tri_down
"2" m08 tri_up
"3" m09 tri_left
"4" m10 tri_right
"8" m11 octagon
"s" m12 square
"p" m13 pentagon
"P" m23 plus (filled)
"*" m14 star
"h" m15 hexagon1
"H" m16 hexagon2
"+" m17 plus
"x" m18 x
"X" m24 x (filled)
"D" m19 diamond
"d" m20 thin_diamond
"|" m21 vline
"_" m22 hline
0 (TICKLEFT) m25 tickleft
1 (TICKRIGHT) m26 tickright
2 (TICKUP) m27 tickup
3 (TICKDOWN) m28 tickdown
4 (CARETLEFT) m29 caretleft
5 (CARETRIGHT) m30 caretright
6 (CARETUP) m31 caretup
7 (CARETDOWN) m32 caretdown
8 (CARETLEFTBASE) m33 caretleft (centered at base)
9 (CARETRIGHTBASE) m34 caretright (centered at base)
10 (CARETUPBASE) m35 caretup (centered at base)
11 (CARETDOWNBASE) m36 caretdown (centered at base)
"None", " " or "" nothing
'$...$' m37 Render the string using mathtext. E.g "$f$" for marker showing the letter f.
verts A list of (x, y) pairs used for Path vertices. The center of the marker is located at (0, 0) and the size is normalized, such that the created path is encapsulated inside the unit cell.
path A Path instance.
(numsides, 0, angle) A regular polygon with numsides sides, rotated by angle.
(numsides, 1, angle) A star-like symbol with numsides sides, rotated by angle.
(numsides, 2, angle) An asterisk with numsides sides, rotated by angle.
Markers and Their Keywords
4 Likes