We can plot in Julia using various packages like pyplot, plotly, and so on. Plots.jl is one such package using which we can plot in Julia.
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 bar graph is created using the bar() function of the Plots package:
using Plots
bar(x, y)
x: These are the data points along the x dimension.y: These are the data points along the y dimension.using Plotsx = [1,2,3]y = [4,5,6]bar(x,y)savefig("output/plot.png")
Plots package.bar() function.plot.png.We can create a histogram in Julia using the histogram() function of the Plots package.
using Plots
histogram(x, nbins, weights, normalize)
x:  These are the data points to be plotted.nbins: This is an integer or vector that defines the number of bins to place the input data points.weights: This is a vector that defines the weights for the data points.normalize: This is a boolean value indicating whether or not to normalize the data points. The default value is false. This denotes that no normalization is performed.using Plotsdata = randn(1000)histogram(data, nbins=20)savefig("output/plot.png")
Plots package.histogram() function, where the number of bins is set to 20.plot.png.Free Resources