logo

Inserting a Line into a Julia Set Image 📂Julia

Inserting a Line into a Julia Set Image

Code

using Plots

scatter(rand(100), randn(100))
plot!([0,1],[0,1])
png("example1")

plot!([.00,.25,.50],[-2,0,-2])
png("example2")

θ = 0:0.01:2π
plot!(.5 .+ cos.(θ)/3, 1.5sin.(θ))
png("example3")

Let’s learn how to insert line segments into the diagram by executing the code above.

Line Segment plot!([0,1],[0,1])

example1.png

Whether you draw just one line segment or something else, the method is the same. For a line segment, you need two points, so you just need to give an array of x coordinates and an array of y coordinates.

Multiple Line Segments plot!([.00,.25,.50],[-2,0,-2])

example2.png

y3 draws two line segments at once. The start and end points of the segments are connected.

Ellipse plot!(.5 .+ cos.(θ)/3, 1.5sin.(θ))

example3.png

By applying the method used to draw multiple line segments, you can also draw an ellipse. Both grammatically and computationally, it’s relatively easier to draw compared to other languages.

Environment

  • OS: Windows
  • julia: v1.6.3