In Julia, we can plot using various packages like pyplot, plotly and more. The Plots.jl
is one such package that can be used to plot in Julia.
The Plots.jl
can be installed using the following commands:
import Pkg;
Pkg.add("Plots")
The first command imports the package manager. The second command downloads and installs the package.
To use the package, execute the following command:
using Plots
In Julia, a scatter plot is created using the scatter()
function of the Plots
package.
using Plots
scatter(x, y)
x
: This is the data points along the x
dimension.y
: This is the data points along the y
dimension.Let’s look at the code below:
using Plotsx = [1, 2, 3, 4, 5]y = [-1, 5, -3, 7, 2]scatter(x,y)savefig("output/plot.png")
Plots
package.x
-dimension data points.y
-dimension data points.scatter()
function.plot.png
.Free Resources