I want to plot the projections of a 2d map on the right and below the 2d plot, but if I show the colorbar the axis are not aligned anymore.
How can I align the axes?
Is there a way to place the colorbar in the bottom right corner to get axes aligned ?
Here is the sample code
using Plots
x = rand(20)
y = rand(20).+10
z = rand(20).*10
l = @layout [a{0.5w,0.5h} b;c _]
plot(layout=l, grid=false,legend=false,link=:both)
plot!(x,y,marker_z=z,seriestype=:scatter,marker=7,subplot=1,colorbar=true)
plot!(z,y,seriestype=:scatter,marker=7,subplot=2)
plot!(x,z,seriestype=:scatter,marker=7,subplot=3)
Could you use the pyplot()
backend for your application? If so, it appears the x-axes are aligned:
using Plots
pyplot() #note the pyplot backend
x = rand(20)
y = rand(20).+10
z = rand(20).*10
l = @layout [a{0.5w,0.5h} b;c _]
pyplotoutput = plot(layout=l, grid=false,legend=false,link=:both)
plot!(x,y,marker_z=z,seriestype=:scatter,marker=7,subplot=1,colorbar=true)
plot!(z,y,seriestype=:scatter,marker=7,subplot=2)
plot!(x,z,seriestype=:scatter,marker=7,subplot=3)
savefig(pyplotoutput, "pyplotoutput.png")
which produces the following:
So it seems this is handled by the backend.
@jheinen is it possible to do it with gr as well?
2 Likes