julialangHow to create plots in JuliaLang?
Plots in JuliaLang can be created using the Plots.jl package. Plots.jl is a plotting metapackage which brings many different plotting packages under a single API.
using Plots
x = -2π:0.1:2π
y = sin.(x)
plot(x, y, label="sin(x)")
The code above creates a plot of the sine function. The first two lines import the Plots.jl package and create an array of x values. The third line creates an array of y values using the sin function. The fourth line creates the plot using the plot function, which takes the x and y arrays as arguments, and adds a label to the plot.
Code explanation
using Plots
- imports the Plots.jl packagex = -2π:0.1:2π
- creates an array of x valuesy = sin.(x)
- creates an array of y values using the sin functionplot(x, y, label="sin(x)")
- creates the plot using the plot function, which takes the x and y arrays as arguments, and adds a label to the plot
Helpful links
More of Julialang
- How to use the println function in JuliaLang?
- How to get JuliaLang version?
- How to test code in JuliaLang?
- How to round numbers in JuliaLang?
- How to use tuples in JuliaLang?
- How to use try catch in JuliaLang?
- How to use lambda functions in JuliaLang?
- How to use Pluto in JuliaLang?
- How to use regular expressions in JuliaLang?
See more codes...