The first image is generated using julia
the second one is generated using python
How to make the first one like the second one ? how to include the exponential fit line and start the axis from 1 ??
what’s your code?
Given that your plots looks like it’s been generated using the Plots
package (there are many plotting packages in Julia, so it’s important to specify which one you are using when asking for help):
The y-axis limits are set using the ylims
keyword, so plot(days, infected, ylims = (1, 100))
will set y-axis limit to go from 1 to 100.
plot!(exp_fit; seriestype=:line, label="Exponential fit")
p2=plot(dayss,numberofinfectedd,color =:green, xlabel=“Days”, ylabel=“Population”,label = “Infected”)
p2=plot(dayss,numberofinfectedd,color =:green, xlabel="Days", ylabel="Population",label = "Infected")
It is still a little unclear to me what you are asking for help with. But here is a way that might plot it similarly to what you are asking for
p2 = plot(dayss, numberofinfected, markershape=:rect, ylims=[1, 100], yscale=:log10, label="Infected", xlabel="Days", ylabel="Population", color=:green)
plot!(p2, expdays, expfit, linestyle=:dash, label="Exponential Fit", color=:green)
It seems unlikely that this is the whole Python code, as the Python version has two lines, one of which is labelled “Exponential Fit”, so that must come from somewhere.
I guess what people having been trying to tell you is that you are looking for something like this:
plot(days, infected, label = "Infected", linetype = :scatterpath)
plot!(days, exp_fit, label = "Exponential Fit", linetype = :dash)
so basically plot(x, y)
plots a line, and plot!(x, y)
adds another line to the same figure. What you need to provide is the x and y data, i.e. the days for the x data, and the data on infected and the exponential fit for the y data.
Many thanks for you comment
the python code is from a paper and I do not have access to the source code
I am trying to reproduce the same results using julia
It seems the same but I do not know how to represent it like original paper
Where should I find “exp_fit” ?
This is a vector that you must make yourself in order be able to plot it. The replies are assuming that you have already done this. If you struggle with this and would like help please specify what sort of exponential fit is being produced and we can point you in the right direction.
You can try the EasyFit package.
using EasyFit, Plots
exp_fit = fitexp(days[1:10], numberofinfected[1:10]) #Looks like you will need to slice the data to get the right fit
plot(days, infected, label = "Infected", linetype = :scatterpath)
plot!(exp_fit.x, exp_fit.y, label = "Exponential Fit", linetype = :dash)