Lines Styles and Markers
Set the basic series attributes in order to choose between solid, dashed or dotted line plots, bar plots, or scatter plots
Dashed/dotted line plots and more
To begin styling our plot, we can begin with setting the following Series attributes:
|seriestype||:path, :sticks, :scatter, :bar|
|linestyle||:solid, :dash, :dot, :dashdot, :dashdotdot|
which will allow us to style the line.
For example, the code to produce a simple dashed line is
using Plots x = 0:0.05:1; y = sin.(2π*x); plot( x, y, seriestype=:path, linestyle=:dash )
while for a dotted line, we simply replace the
This is how some different combinations of
linestyle look like.
Note that changing the
seriestype of a column is equivalent to using commands such as
Custom Marker Shapes
Optionally, we can also add different kinds of marker shapes on top of the selected lines, with the following attributes:
Let’s see a full example
using Plots x = 0:0.05:1; y = sin.(2π*x); plot( x, y, seriestype=:sticks, linestyle=:dash, lw = 3, seriescolor = :green, marker = :circle, markersize = 8, markercolor = :green, markerstrokecolor = :green, )
More succintly with line and marker tuples
When composing many different options to customize a plot, setting so many attributes one by one can become annoying.
More succintly, we can also use the equivalent syntax:
plot( x, y, line=(3,:green,:dash,:sticks), marker=(:circle,8,:green,:green) )
Note that, remarkably, the
marker tuples can contain their elements in different orders, so
line=(2,:green,:dash,:path) will work as well.
As for picking different colors for our lines or markers, the
Color Type can stand for any symbol of the following list, like