Issues with secondary y-axis in Plots.jl

Hello all, :slight_smile:

I am working on a plot with two y-axis. The plot is showing how a quantity is changing over time and I would like to have on the left axis its nominal value and on the right axis the percentage variation.

Now, with these simple lines I am able to produce the desired plot:

ttime = 0:10
nominal = exp.(-ttime/2)
percentace = 100*(nominal .- nominal[1])/nominal[1]
plot(ttime, nominal,lw=2,label="nominal")
plot!(gridalpha=0.3)
xlabel!("Time")
ylabel!("Nominal")
axis2 = twinx()
ylims!(axis2,100*(ylims()[1]-nominal[1])/nominal[1],100*(ylims()[2]-nominal[1])/nominal[1])
ylabel!(axis2,"Percentage")

However, the final plot misses any horizontal grid while I would like to keep it with the reference of the left y-axis values:

Can anybody help here? :grinning:

Assign the left y-axis plot to axis1 and then add plot!(axis1, grid=true) as the last line in your code snippet.

edited code
using Plots; gr(dpi=600)

ttime = 0:10
nominal = exp.(-ttime/2)
percentace = 100*(nominal .- nominal[1])/nominal[1]
axis1 = plot(ttime, nominal,lw=2,label="nominal")
plot!(gridalpha=0.3)
xlabel!("Time")
ylabel!("Nominal")
axis2 = twinx()
# plot!(grid=:on)
ylims!(axis2, 100*(ylims()[1]-nominal[1])/nominal[1], 100*(ylims()[2]-nominal[1])/nominal[1])
ylabel!(axis2, "Percentage")
plot!(axis1, grid=true)