Julia, Software Development, Statistics

Plot XY Graph in Julia Using Data Points

Plotting numbers in the XY graph in Julia can help us create the big picture. This post shows how to plot data points in a graph using the Plots and GR packages. These data points are our x-y coordinates.

Install Plots And GR Packages In Julia

Before we install these packages, we need to install Julia on our machine. Once installed and configured, start up the Julia interpreter. We can either use the Pkg.add() command in the current shell mode or enter package mode to install packages. When we are in the current shell mode, we use the following commands in Julia. The Plots package does not need to come first.

Alternatively, we run similar commands in the package mode to install the Plots and GR packages. Note that we need to go back to the shell mode to plot points in the graphs. To enter the package mode, type ] after the julia> prompt.

The package mode prompt replaces the shell mode prompt. Then, we use the commands – add Plots and add GR, as follows.

The Plots package is a visualization interface and toolset where users interact directly by issuing commands together with data points. It wraps the GR package, which is a framework for visualization. The GR package has different types of graphs that we can use. Do we need Plots when we are using GR? It depends. We can use GR without Plots. However, visualization is complicated, but the Plots package makes it easier for Julia to plot X Y on graphs.

Plot XY Data Points In Graph

We can now plot some XY data points in a graph and display it. On the Julia command prompt, run the following commands.

Our data points are limited, and we have the same values for both the x-y coordinates. The plot command will display the graph in a separate window, as shown below. It may take a few seconds to display the X Y graph.

Plot XY Graph In Julia

After learning how to plot XY data points in graphs in Julia using Plots and GR, we can now explore other graphs with more complex data.

Loading

Got comments or suggestions? We disabled the comments on this site to fight off spammers, but you can still contact us via our Facebook page!.


You Might Also Like