commit
c7c10e769d
@ -98,36 +98,36 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true,
|
|||||||
mwidth, mheight, width, height = GR.inqdspsize()
|
mwidth, mheight, width, height = GR.inqdspsize()
|
||||||
w, h = d[:size]
|
w, h = d[:size]
|
||||||
viewport = zeros(4)
|
viewport = zeros(4)
|
||||||
|
vp = float(subplot)
|
||||||
if w > h
|
if w > h
|
||||||
ratio = float(h) / w
|
ratio = float(h) / w
|
||||||
msize = mwidth * w / width
|
msize = mwidth * w / width
|
||||||
GR.setwsviewport(0, msize, 0, msize * ratio)
|
GR.setwsviewport(0, msize, 0, msize * ratio)
|
||||||
GR.setwswindow(0, 1, 0, ratio)
|
GR.setwswindow(0, 1, 0, ratio)
|
||||||
viewport[1] = subplot[1] + 0.125 * (subplot[2] - subplot[1])
|
vp[3] *= ratio
|
||||||
viewport[2] = subplot[1] + 0.95 * (subplot[2] - subplot[1])
|
vp[4] *= ratio
|
||||||
viewport[3] = ratio * (subplot[3] + 0.125 * (subplot[4] - subplot[3]))
|
|
||||||
viewport[4] = ratio * (subplot[3] + 0.95 * (subplot[4] - subplot[3]))
|
|
||||||
else
|
else
|
||||||
ratio = float(w) / h
|
ratio = float(w) / h
|
||||||
msize = mheight * h / height
|
msize = mheight * h / height
|
||||||
GR.setwsviewport(0, msize * ratio, 0, msize)
|
GR.setwsviewport(0, msize * ratio, 0, msize)
|
||||||
GR.setwswindow(0, ratio, 0, 1)
|
GR.setwswindow(0, ratio, 0, 1)
|
||||||
viewport[1] = ratio * (subplot[1] + 0.125 * (subplot[2] - subplot[1]))
|
vp[1] *= ratio
|
||||||
viewport[2] = ratio * (subplot[1] + 0.95 * (subplot[2] - subplot[1]))
|
vp[2] *= ratio
|
||||||
viewport[3] = subplot[3] + 0.125 * (subplot[4] - subplot[3])
|
|
||||||
viewport[4] = subplot[3] + 0.95 * (subplot[4] - subplot[3])
|
|
||||||
end
|
end
|
||||||
|
viewport[1] = vp[1] + 0.125 * (vp[2] - vp[1])
|
||||||
|
viewport[2] = vp[1] + 0.95 * (vp[2] - vp[1])
|
||||||
|
viewport[3] = vp[3] + 0.125 * (vp[4] - vp[3])
|
||||||
|
if w > h
|
||||||
|
viewport[3] += (1 - (subplot[4] - subplot[3])^2) * 0.02
|
||||||
|
end
|
||||||
|
viewport[4] = vp[3] + 0.95 * (vp[4] - vp[3])
|
||||||
|
|
||||||
if haskey(d, :background_color)
|
if haskey(d, :background_color)
|
||||||
GR.savestate()
|
GR.savestate()
|
||||||
GR.selntran(0)
|
GR.selntran(0)
|
||||||
GR.setfillintstyle(GR.INTSTYLE_SOLID)
|
GR.setfillintstyle(GR.INTSTYLE_SOLID)
|
||||||
GR.setfillcolorind(gr_getcolorind(d[:background_color]))
|
GR.setfillcolorind(gr_getcolorind(d[:background_color]))
|
||||||
if w > h
|
GR.fillrect(vp[1], vp[2], vp[3], vp[4])
|
||||||
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.selntran(1)
|
||||||
GR.restorestate()
|
GR.restorestate()
|
||||||
c = getColor(d[:background_color])
|
c = getColor(d[:background_color])
|
||||||
@ -145,6 +145,7 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true,
|
|||||||
cmap = false
|
cmap = false
|
||||||
axes_2d = true
|
axes_2d = true
|
||||||
grid_flag = get(d, :grid, true)
|
grid_flag = get(d, :grid, true)
|
||||||
|
outside_ticks = false
|
||||||
|
|
||||||
for axis = 1:2
|
for axis = 1:2
|
||||||
xmin = ymin = typemax(Float64)
|
xmin = ymin = typemax(Float64)
|
||||||
@ -176,12 +177,15 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true,
|
|||||||
xmin, xmax, ymin, ymax = 0, 1, 0, 1
|
xmin, xmax, ymin, ymax = 0, 1, 0, 1
|
||||||
x, y = p[:x], p[:y]
|
x, y = p[:x], p[:y]
|
||||||
else
|
else
|
||||||
if p[:linetype] in [:contour, :surface]
|
if p[:linetype] in [:contour, :surface, :heatmap]
|
||||||
cmap = true
|
cmap = true
|
||||||
end
|
end
|
||||||
if p[:linetype] in [:surface, :wireframe, :path3d, :scatter3d]
|
if p[:linetype] in [:surface, :wireframe, :path3d, :scatter3d]
|
||||||
axes_2d = false
|
axes_2d = false
|
||||||
end
|
end
|
||||||
|
if p[:linetype] == :heatmap
|
||||||
|
outside_ticks = true
|
||||||
|
end
|
||||||
x, y = p[:x], p[:y]
|
x, y = p[:x], p[:y]
|
||||||
end
|
end
|
||||||
if p[:linetype] != :pie
|
if p[:linetype] != :pie
|
||||||
@ -267,6 +271,9 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true,
|
|||||||
GR.setlinewidth(1)
|
GR.setlinewidth(1)
|
||||||
GR.setlinecolorind(fg)
|
GR.setlinecolorind(fg)
|
||||||
ticksize = 0.0075 * diag
|
ticksize = 0.0075 * diag
|
||||||
|
if outside_ticks
|
||||||
|
ticksize = -ticksize
|
||||||
|
end
|
||||||
if grid_flag && fg == 1
|
if grid_flag && fg == 1
|
||||||
GR.grid(xtick, ytick, 0, 0, majorx, majory)
|
GR.grid(xtick, ytick, 0, 0, majorx, majory)
|
||||||
end
|
end
|
||||||
@ -285,14 +292,14 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true,
|
|||||||
GR.savestate()
|
GR.savestate()
|
||||||
GR.settextalign(GR.TEXT_HALIGN_CENTER, GR.TEXT_VALIGN_TOP)
|
GR.settextalign(GR.TEXT_HALIGN_CENTER, GR.TEXT_VALIGN_TOP)
|
||||||
GR.settextcolorind(fg)
|
GR.settextcolorind(fg)
|
||||||
GR.text(0.5 * (viewport[1] + viewport[2]), min(ratio, 1), d[:title])
|
GR.text(0.5 * (viewport[1] + viewport[2]), vp[4], d[:title])
|
||||||
GR.restorestate()
|
GR.restorestate()
|
||||||
end
|
end
|
||||||
if get(d, :xlabel, "") != ""
|
if get(d, :xlabel, "") != ""
|
||||||
GR.savestate()
|
GR.savestate()
|
||||||
GR.settextalign(GR.TEXT_HALIGN_CENTER, GR.TEXT_VALIGN_BOTTOM)
|
GR.settextalign(GR.TEXT_HALIGN_CENTER, GR.TEXT_VALIGN_BOTTOM)
|
||||||
GR.settextcolorind(fg)
|
GR.settextcolorind(fg)
|
||||||
GR.text(0.5 * (viewport[1] + viewport[2]), 0, d[:xlabel])
|
GR.text(0.5 * (viewport[1] + viewport[2]), vp[3], d[:xlabel])
|
||||||
GR.restorestate()
|
GR.restorestate()
|
||||||
end
|
end
|
||||||
if get(d, :ylabel, "") != ""
|
if get(d, :ylabel, "") != ""
|
||||||
@ -300,7 +307,7 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true,
|
|||||||
GR.settextalign(GR.TEXT_HALIGN_CENTER, GR.TEXT_VALIGN_TOP)
|
GR.settextalign(GR.TEXT_HALIGN_CENTER, GR.TEXT_VALIGN_TOP)
|
||||||
GR.setcharup(-1, 0)
|
GR.setcharup(-1, 0)
|
||||||
GR.settextcolorind(fg)
|
GR.settextcolorind(fg)
|
||||||
GR.text(0, 0.5 * (viewport[3] + viewport[4]), d[:ylabel])
|
GR.text(vp[1], 0.5 * (viewport[3] + viewport[4]), d[:ylabel])
|
||||||
GR.restorestate()
|
GR.restorestate()
|
||||||
end
|
end
|
||||||
if get(d, :yrightlabel, "") != ""
|
if get(d, :yrightlabel, "") != ""
|
||||||
@ -308,7 +315,7 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true,
|
|||||||
GR.settextalign(GR.TEXT_HALIGN_CENTER, GR.TEXT_VALIGN_TOP)
|
GR.settextalign(GR.TEXT_HALIGN_CENTER, GR.TEXT_VALIGN_TOP)
|
||||||
GR.setcharup(1, 0)
|
GR.setcharup(1, 0)
|
||||||
GR.settextcolorind(fg)
|
GR.settextcolorind(fg)
|
||||||
GR.text(1, 0.5 * (viewport[3] + viewport[4]), d[:yrightlabel])
|
GR.text(vp[2], 0.5 * (viewport[3] + viewport[4]), d[:yrightlabel])
|
||||||
GR.restorestate()
|
GR.restorestate()
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -497,6 +504,18 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true,
|
|||||||
viewport[3], viewport[4])
|
viewport[3], viewport[4])
|
||||||
GR.colormap()
|
GR.colormap()
|
||||||
end
|
end
|
||||||
|
elseif p[:linetype] == :heatmap
|
||||||
|
x, y, z = p[:x], p[:y], p[:z].surf
|
||||||
|
zmin, zmax = GR.adjustrange(minimum(z), maximum(z))
|
||||||
|
GR.setspace(zmin, zmax, 0, 90)
|
||||||
|
GR.setcolormap(GR.COLORMAP_COOLWARM)
|
||||||
|
z = reshape(z, length(x) * length(y))
|
||||||
|
GR.surface(x, y, z, GR.OPTION_CELL_ARRAY)
|
||||||
|
if cmap
|
||||||
|
GR.setviewport(viewport[2] + 0.02, viewport[2] + 0.05,
|
||||||
|
viewport[3], viewport[4])
|
||||||
|
GR.colormap()
|
||||||
|
end
|
||||||
elseif p[:linetype] in [:path3d, :scatter3d]
|
elseif p[:linetype] in [:path3d, :scatter3d]
|
||||||
x, y, z = p[:x], p[:y], p[:z]
|
x, y, z = p[:x], p[:y], p[:z]
|
||||||
zmin, zmax = GR.adjustrange(minimum(z), maximum(z))
|
zmin, zmax = GR.adjustrange(minimum(z), maximum(z))
|
||||||
|
|||||||
@ -241,7 +241,7 @@ supportedArgs(::GRBackend) = [
|
|||||||
supportedAxes(::GRBackend) = _allAxes
|
supportedAxes(::GRBackend) = _allAxes
|
||||||
supportedTypes(::GRBackend) = [:none, :line, :path, :steppre, :steppost, :sticks,
|
supportedTypes(::GRBackend) = [:none, :line, :path, :steppre, :steppost, :sticks,
|
||||||
:scatter, :hist2d, :hexbin, :hist, :density, :bar,
|
:scatter, :hist2d, :hexbin, :hist, :density, :bar,
|
||||||
:hline, :vline, :contour, :path3d, :scatter3d, :surface,
|
:hline, :vline, :contour, :heatmap, :path3d, :scatter3d, :surface,
|
||||||
:wireframe, :ohlc, :pie]
|
:wireframe, :ohlc, :pie]
|
||||||
supportedStyles(::GRBackend) = [:auto, :solid, :dash, :dot, :dashdot, :dashdotdot]
|
supportedStyles(::GRBackend) = [:auto, :solid, :dash, :dot, :dashdot, :dashdotdot]
|
||||||
supportedMarkers(::GRBackend) = vcat(_allMarkers, Shape)
|
supportedMarkers(::GRBackend) = vcat(_allMarkers, Shape)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user