Drawing shapes
The Plots
package exports the Shape
type to construct polygons. This section will teach us how to use it to create custom shapes with Plots
. This will be helpful when drawing or while creating novel plotting types. We can also take advantage of Shape
to design custom markers. The Shape
constructor takes the vertices coordinates of the desired polygon. We can pass them in two different ways:
- We can give a vector for each axis containing the vertex coordinates for that dimension. For example, we can call
Shape(x, y)
if thex
andy
variables are vectors of numbers of the same length. This is one of the ways we usually call theplot
function; that is,plot(x, y)
. - We can give a single vector containing a tuple of numbers, with each tuple containing a vertex’s (x, y) coordinates. Interestingly, we can also call
plot
or other plotting functions such asscatter
with that input. For example,plot([1, 2, 3], [6, 7, 5])
andplot([(1, 6), (2, 7), (3, 5)])
are...