Home > Blockchain >  ylabel location in stacked subplots in julia
ylabel location in stacked subplots in julia

Time:06-28

Is there a way to center align y-label in row-wise stack plots in Julia

stacked subplot

pyplot(grid=:false, frame=:box)
x=LinRange(-π,π,1000)
p1=plot(x,10*sin.(10*x), xticks=:false,yticks=:false,ylabel="Intensity")
p2=plot(x,exp.(x),xlabel=L"\theta",yticks=:false)
plot!(p1,p2,layout=(2,1),link=:all,top_margin=-1mm)

Y label is positioned at the top. How to place it at center

CodePudding user response:

You can try:

pyplot(grid=:false, frame=:box)
x=LinRange(-π,π,1000)
p1=plot(x,10*sin.(10*x), xticks=:false,yticks=:false,ylabel="Intensity")
p2=plot(x,exp.(x),xlabel="θ",yticks=:false)
plot!(p1,p2,layout=(2,1),link=:all, 
legend=:top
)

enter image description here

Or use :left to center vertical on the y-axis.

CodePudding user response:

Thanks Rene, but that's not what I was intended to. I want Ylabel ("Intensity") to be at the center and not the plot legends. yguidefontvalign command is used for that purpose, but it seems to be not working here

pyplot(grid=:false, frame=:box)
x=LinRange(-π,π,1000)
p1=plot(x,10*sin.(10*x), xticks=:false,yticks=:false)
p2=plot(x,exp.(x),xlabel="\theta",yticks=:false)
plot!(p1,p2,layout=(2,1),link=:none,yguidefontvalign=:center,yguide=:Intensity,top_margin=-1mm
       )

In addition it prints ylabel on both the plots

stackplot

I am after some sort of this image

  • Related