Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I overlay two plots in Julia

I would like to overlay these two plots. In my code, I only manage to plot them side by side.

using PyPlot
x = [μ, μ]
y = histogram(walks[end, :], bins=20, legend=nothing)

plot(plot(x), y)

enter image description here

like image 783
Struggling_Student Avatar asked Jun 24 '21 15:06

Struggling_Student


People also ask

How to download and install plot package in Julia?

Step 1: Open the terminal and add the command Julia. Then write the following command. It will import the package manager for Julia. This is the first step toward installing the plot package. Step 2: Then the following command should be written in the terminal. This command helps us to download the plot package in Julia.

How do I include multiple plots in one figure?

Sometimes you may want to include multiple plots in one figure. For example, you draw one plot, and then add a smaller size plot on top of it as an overlay. Gnuplot has a multiplot feature which allows you to create various kinds of multiplot layouts including stacked plots or overlay plots, etc.

What is the difference between Julia and Python plot?

Julia is a type of programming language. It is an open sources language. It is mostly used for Data Analytics & Machine Learning purposes. By using Julia we can plot graphs as well. It is the similar plots that we got by using pyplots. But using plots in Julia is very easy compared to Python plots.

How to use the plots package in Python?

The package Plots is a high-level plotting package, also referred to as ‘back-ends’ interfaces with other plotting packages. To start using the Plots package, type the following command − For plotting a function, we need to switch back to PyPlot back-end as follows −


Video Answer


1 Answers

Just use the plotting functions with ! versions.

For an example:

x = randn(100).*10 .+ 100;
using Plots
histogram(x, bins=10)
plot!(80:120, rand(1:25,41))

enter image description here

like image 171
Przemyslaw Szufel Avatar answered Oct 11 '22 04:10

Przemyslaw Szufel