Improved subplot layout
This commit is contained in:
parent
51c45456c3
commit
51eeed3d50
@ -54,19 +54,19 @@ function gr_display(plt::Plot{GRPackage}, clear=true, update=true,
|
||||
msize = mwidth * w / width
|
||||
GR.setwsviewport(0, msize, 0, msize * ratio)
|
||||
GR.setwswindow(0, 1, 0, ratio)
|
||||
viewport[1] = subplot[1] + 0.1 * (subplot[2] - subplot[1])
|
||||
viewport[2] = subplot[1] + 0.95 * (subplot[2] - subplot[1])
|
||||
viewport[3] = ratio * (subplot[3] + 0.1 * (subplot[4] - subplot[3]))
|
||||
viewport[4] = ratio * (subplot[3] + 0.95 * (subplot[4] - subplot[3]))
|
||||
viewport[1] = subplot[1] + 0.125 * (subplot[2] - subplot[1])
|
||||
viewport[2] = subplot[1] + 0.95 * (subplot[2] - subplot[1])
|
||||
viewport[3] = ratio * (subplot[3] + 0.125 * (subplot[4] - subplot[3]))
|
||||
viewport[4] = ratio * (subplot[3] + 0.95 * (subplot[4] - subplot[3]))
|
||||
else
|
||||
ratio = float(w) / h
|
||||
msize = mheight * h / height
|
||||
GR.setwsviewport(0, msize * ratio, 0, msize)
|
||||
GR.setwswindow(0, ratio, 0, 1)
|
||||
viewport[1] = ratio * (subplot[1] + 0.1 * (subplot[2] - subplot[1]))
|
||||
viewport[2] = ratio * (subplot[1] + 0.95 * (subplot[2] - subplot[1]))
|
||||
viewport[3] = subplot[3] + 0.1 * (subplot[4] - subplot[3])
|
||||
viewport[4] = subplot[3] + 0.95 * (subplot[4] - subplot[3])
|
||||
viewport[1] = ratio * (subplot[1] + 0.125 * (subplot[2] - subplot[1]))
|
||||
viewport[2] = ratio * (subplot[1] + 0.95 * (subplot[2] - subplot[1]))
|
||||
viewport[3] = subplot[3] + 0.125 * (subplot[4] - subplot[3])
|
||||
viewport[4] = subplot[3] + 0.95 * (subplot[4] - subplot[3])
|
||||
end
|
||||
|
||||
if haskey(d, :background_color)
|
||||
@ -74,7 +74,11 @@ function gr_display(plt::Plot{GRPackage}, clear=true, update=true,
|
||||
GR.selntran(0)
|
||||
GR.setfillintstyle(GR.INTSTYLE_SOLID)
|
||||
GR.setfillcolorind(gr_getcolorind(d[:background_color]))
|
||||
GR.fillrect(0, 1, 0, 1)
|
||||
if w > h
|
||||
GR.fillrect(subplot[1], subplot[2], ratio*subplot[3], ratio*subplot[4])
|
||||
else
|
||||
GR.fillrect(ratio*subplot[1], ratio*subplot[2], subplot[3], subplot[4])
|
||||
end
|
||||
GR.selntran(1)
|
||||
GR.restorestate()
|
||||
end
|
||||
@ -141,7 +145,7 @@ function gr_display(plt::Plot{GRPackage}, clear=true, update=true,
|
||||
end
|
||||
|
||||
if num_axes == 2 || !axes_2d
|
||||
viewport[2] -= 0.05
|
||||
viewport[2] -= 0.0525
|
||||
end
|
||||
if cmap
|
||||
viewport[2] -= 0.1
|
||||
@ -205,13 +209,13 @@ function gr_display(plt::Plot{GRPackage}, clear=true, update=true,
|
||||
if get(d, :title, "") != ""
|
||||
GR.savestate()
|
||||
GR.settextalign(GR.TEXT_HALIGN_CENTER, GR.TEXT_VALIGN_TOP)
|
||||
GR.text(0.5, min(ratio, 1), d[:title])
|
||||
GR.text(0.5 * (viewport[1] + viewport[2]), min(ratio, 1), d[:title])
|
||||
GR.restorestate()
|
||||
end
|
||||
if get(d, :xlabel, "") != ""
|
||||
GR.savestate()
|
||||
GR.settextalign(GR.TEXT_HALIGN_CENTER, GR.TEXT_VALIGN_BOTTOM)
|
||||
GR.text(0.5, 0, d[:xlabel])
|
||||
GR.text(0.5 * (viewport[1] + viewport[2]), 0, d[:xlabel])
|
||||
GR.restorestate()
|
||||
end
|
||||
if get(d, :ylabel, "") != ""
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user