Fixed some bugs in gr.jl
- Turn off interpolation for heatmaps - Fixed bug plotting scatter after heatmap (scatter drew to the colorbar viewport) - Don't draw superfluous legends
This commit is contained in:
parent
fe5789d747
commit
5109c6f72b
@ -438,9 +438,9 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true,
|
|||||||
|
|
||||||
GR.setcolormap(1000 + GR.COLORMAP_COOLWARM)
|
GR.setcolormap(1000 + GR.COLORMAP_COOLWARM)
|
||||||
|
|
||||||
legend = false
|
legend = falses(length(plt.seriesargs))
|
||||||
|
|
||||||
for p in plt.seriesargs
|
for (ind, p) in enumerate(plt.seriesargs)
|
||||||
lt = p[:linetype]
|
lt = p[:linetype]
|
||||||
if lt in (:hist2d, :hexbin, :contour, :surface, :wireframe, :heatmap)
|
if lt in (:hist2d, :hexbin, :contour, :surface, :wireframe, :heatmap)
|
||||||
if isa(p[:fillcolor], ColorGradient)
|
if isa(p[:fillcolor], ColorGradient)
|
||||||
@ -473,13 +473,13 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true,
|
|||||||
end
|
end
|
||||||
GR.polyline(p[:x], p[:y])
|
GR.polyline(p[:x], p[:y])
|
||||||
end
|
end
|
||||||
legend = true
|
legend[ind] = true
|
||||||
end
|
end
|
||||||
if lt == :line
|
if lt == :line
|
||||||
if length(p[:x]) > 1
|
if length(p[:x]) > 1
|
||||||
gr_polyline(p[:x], p[:y])
|
gr_polyline(p[:x], p[:y])
|
||||||
end
|
end
|
||||||
legend = true
|
legend[ind] = true
|
||||||
elseif lt in [:steppre, :steppost]
|
elseif lt in [:steppre, :steppost]
|
||||||
n = length(p[:x])
|
n = length(p[:x])
|
||||||
x = zeros(2*n + 1)
|
x = zeros(2*n + 1)
|
||||||
@ -499,13 +499,13 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true,
|
|||||||
if n > 1
|
if n > 1
|
||||||
GR.polyline(x, y)
|
GR.polyline(x, y)
|
||||||
end
|
end
|
||||||
legend = true
|
legend[ind] = true
|
||||||
elseif lt == :sticks
|
elseif lt == :sticks
|
||||||
x, y = p[:x], p[:y]
|
x, y = p[:x], p[:y]
|
||||||
for i = 1:length(y)
|
for i = 1:length(y)
|
||||||
GR.polyline([x[i], x[i]], [ymin, y[i]])
|
GR.polyline([x[i], x[i]], [ymin, y[i]])
|
||||||
end
|
end
|
||||||
legend = true
|
legend[ind] = true
|
||||||
elseif lt == :scatter || (p[:markershape] != :none && axes_2d)
|
elseif lt == :scatter || (p[:markershape] != :none && axes_2d)
|
||||||
GR.setmarkercolorind(gr_getcolorind(p[:markercolor]))
|
GR.setmarkercolorind(gr_getcolorind(p[:markercolor]))
|
||||||
gr_setmarkershape(p)
|
gr_setmarkershape(p)
|
||||||
@ -526,7 +526,7 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true,
|
|||||||
gr_polymarker(p, [p[:x][i]], [p[:y][i]])
|
gr_polymarker(p, [p[:x][i]], [p[:y][i]])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
legend = true
|
legend[ind] = true
|
||||||
elseif lt == :bar
|
elseif lt == :bar
|
||||||
y = p[:y]
|
y = p[:y]
|
||||||
for i = 1:length(y)
|
for i = 1:length(y)
|
||||||
@ -577,6 +577,7 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true,
|
|||||||
charheight = max(0.016 * diag, 0.01)
|
charheight = max(0.016 * diag, 0.01)
|
||||||
GR.setcharheight(charheight)
|
GR.setcharheight(charheight)
|
||||||
GR.colormap()
|
GR.colormap()
|
||||||
|
GR.setviewport(viewport[1], viewport[2], viewport[3], viewport[4])
|
||||||
elseif lt == :contour
|
elseif lt == :contour
|
||||||
x, y, z = p[:x], p[:y], transpose_z(p, p[:z].surf, false)
|
x, y, z = p[:x], p[:y], transpose_z(p, p[:z].surf, false)
|
||||||
zmin, zmax = gr_getzlims(d, minimum(z), maximum(z), false)
|
zmin, zmax = gr_getzlims(d, minimum(z), maximum(z), false)
|
||||||
@ -597,6 +598,7 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true,
|
|||||||
charheight = max(0.016 * diag, 0.01)
|
charheight = max(0.016 * diag, 0.01)
|
||||||
GR.setcharheight(charheight)
|
GR.setcharheight(charheight)
|
||||||
GR.axes(0, ztick, xmax, zmin, 0, 1, 0.005)
|
GR.axes(0, ztick, xmax, zmin, 0, 1, 0.005)
|
||||||
|
GR.setviewport(viewport[1], viewport[2], viewport[3], viewport[4])
|
||||||
elseif lt in [:surface, :wireframe]
|
elseif lt in [:surface, :wireframe]
|
||||||
x, y, z = p[:x], p[:y], transpose_z(p, p[:z].surf, false)
|
x, y, z = p[:x], p[:y], transpose_z(p, p[:z].surf, false)
|
||||||
zmin, zmax = gr_getzlims(d, minimum(z), maximum(z), true)
|
zmin, zmax = gr_getzlims(d, minimum(z), maximum(z), true)
|
||||||
@ -633,11 +635,12 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true,
|
|||||||
zmin, zmax = gr_getzlims(d, minimum(z), maximum(z), true)
|
zmin, zmax = gr_getzlims(d, minimum(z), maximum(z), true)
|
||||||
GR.setspace(zmin, zmax, 0, 90)
|
GR.setspace(zmin, zmax, 0, 90)
|
||||||
z = reshape(z, length(x) * length(y))
|
z = reshape(z, length(x) * length(y))
|
||||||
GR.surface(x, y, z, GR.OPTION_CELL_ARRAY)
|
GR.surface(x, y, z, GR.OPTION_COLORED_MESH)
|
||||||
if cmap
|
if cmap
|
||||||
GR.setviewport(viewport[2] + 0.02, viewport[2] + 0.05,
|
GR.setviewport(viewport[2] + 0.02, viewport[2] + 0.05,
|
||||||
viewport[3], viewport[4])
|
viewport[3], viewport[4])
|
||||||
GR.colormap()
|
GR.colormap()
|
||||||
|
GR.setviewport(viewport[1], viewport[2], viewport[3], viewport[4])
|
||||||
end
|
end
|
||||||
elseif lt in [:path3d, :scatter3d]
|
elseif lt in [:path3d, :scatter3d]
|
||||||
x, y, z = p[:x], p[:y], p[:z]
|
x, y, z = p[:x], p[:y], p[:z]
|
||||||
@ -762,15 +765,15 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true,
|
|||||||
GR.restorestate()
|
GR.restorestate()
|
||||||
end
|
end
|
||||||
|
|
||||||
if d[:legend] != :none && legend
|
if d[:legend] != :none && any(legend) == true
|
||||||
GR.savestate()
|
GR.savestate()
|
||||||
GR.selntran(0)
|
GR.selntran(0)
|
||||||
GR.setscale(0)
|
GR.setscale(0)
|
||||||
w = 0
|
w = 0
|
||||||
i = 0
|
i = 0
|
||||||
n = 0
|
n = 0
|
||||||
for p in plt.seriesargs
|
for (ind, p) in enumerate(plt.seriesargs)
|
||||||
if p[:label] == ""
|
if !legend[ind] || p[:label] == ""
|
||||||
continue
|
continue
|
||||||
end
|
end
|
||||||
n += 1
|
n += 1
|
||||||
@ -793,8 +796,8 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true,
|
|||||||
GR.setlinewidth(1)
|
GR.setlinewidth(1)
|
||||||
GR.drawrect(px - 0.08, px + w + 0.02, py + dy, py - dy * n)
|
GR.drawrect(px - 0.08, px + w + 0.02, py + dy, py - dy * n)
|
||||||
i = 0
|
i = 0
|
||||||
for p in plt.seriesargs
|
for (ind, p) in enumerate(plt.seriesargs)
|
||||||
if p[:label] == ""
|
if !legend[ind] || p[:label] == ""
|
||||||
continue
|
continue
|
||||||
end
|
end
|
||||||
GR.setlinewidth(p[:linewidth])
|
GR.setlinewidth(p[:linewidth])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user