Scatter Plot
It is used to reveal a pattern in the plotted data. To plot a scatter plot using the scatter() function. Below is the Julia program to plot a scatter plot:
Julia
# Julia program to plot a # scatter plot # Importing Module using PyPlot; # Defining values for the axes x = [ 5 , 7 , 8 , 7 , 2 , 17 , 2 , 9 , 4 , 11 , 12 , 9 , 6 ] y = [ 99 , 86 , 87 , 88 , 111 , 86 , 103 , 87 , 94 , 78 , 77 , 85 , 86 ] # Plotting scatter plot scatter(x, y, color = "red" ); # Setting title for the scatter plot # and labels for the axes title( "A simple Scatter Plot" ); xlabel( "This is X-Axis" ); ylabel( "This is Y-Axis" ); PyPlot.show(); |
Output:
Explanation: Here also, inside of the scatter() function, the variables are passed alongside another argument color which is used to define the color of each dot of the scatter plot.
Julia – Working with Matplotlib’s Pyplot Class
Data visualization is the process of representing the available data diagrammatically. There are packages that can be installed to visualize the data in Julia. Here, PyPlot class of the Matplotlib Module in Julia will be used for plotting.
To install the PyPlot package in Julia, the Matplotlib package of Python must be installed on the user’s device. Using the Pkg command we will install PyPlot in Julia Command-Line. Open the Julia terminal and type the following command:
using Pkg;
Pkg.add(“PyPlot”);
Contact Us