Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to place two plots next to each other in Julia?

Tags:

julia

I want to plot the following line plot and scatter plot side-by-side in Julia. The MWE is given below:

using Plots
x = 1:10;
y = rand(10);
plot(x, y)
scatter(x, y)

enter image description here

enter image description here

But doing it this one shows them one below the other, as seperate plots.

like image 667
Qwerty Avatar asked Mar 15 '20 17:03

Qwerty


People also ask

How do you display plots in Julia?

A Plot is only displayed when returned (a semicolon will suppress the return), or if explicitly displayed with display(plt) , gui() , or by adding show = true to your plot command.

How do you plot a vertical line in Julia?

If you want to be more precise with how you draw vertical lines, just do it yourself with the normal :path seriestype and separate each line segment with a NaN. For future reference, the command is: vline([1,2,3]) # vertical lines at x = 1, 2 and 3.


1 Answers

Using layout = (1, 2) might help!

using Plots
x = 1:10;
y = rand(10);
plot1 = plot(x, y);
plot2 = scatter(x, y);
plot(plot1, plot2, layout = (1, 2), legend = false)

enter image description here

like image 82
Qwerty Avatar answered Sep 28 '22 16:09

Qwerty