JuliaPlots
JuliaPlots is one of the most popular data visualization packages for Julia as it is easy to use and interfaces with many other Julia packages.
Installation & Setup
To begin, import the "Plots" package and initialize it with the following code.
Creating a Plot
Use plot
to create a new plot, and plot!
to add to an existing plot
To create a first plot of sin(x), we will assign two variables and use the plot
function to visualize them.
Output
Adding/Modifying Plot Attributes
There are many attributes you can modify to incorporate additional detail and/or change the style of a plot, such as titles, axis labels, line width, and legends, to name a few. In Plots, changing the modifier is as easy as typing the name of the attribute followed by an exclamation point (xlabel!
). Below are some examples of attribute addition and modification.
The default for Plots is modifying the current plot. To modify the attribute of a plot other than the current one, include the plot name following the attribute. For example, to change the x-axis label of a plot called "plotname", you would write: xlabel!(plotname, "x")
Output
Saving Plots
To save your plots from the Plots package, there are a few options depending on whether you want the plot to save as a .png or .pdf.
Resources
Last updated