Added path3d and scatter3d functions
This commit is contained in:
parent
0c8cd74e28
commit
87b050fad2
@ -92,7 +92,7 @@ function gr_display(plt::Plot{GRPackage}, clear=true, update=true,
|
|||||||
if p[:linetype] in [:contour, :surface]
|
if p[:linetype] in [:contour, :surface]
|
||||||
cmap = true
|
cmap = true
|
||||||
end
|
end
|
||||||
if p[:linetype] in [:surface, :wireframe]
|
if p[:linetype] in [:surface, :wireframe, :path3d, :scatter3d]
|
||||||
axes_2d = false
|
axes_2d = false
|
||||||
end
|
end
|
||||||
x, y = p[:x], p[:y]
|
x, y = p[:x], p[:y]
|
||||||
@ -252,7 +252,7 @@ function gr_display(plt::Plot{GRPackage}, clear=true, update=true,
|
|||||||
GR.polyline([x[i], x[i]], [ymin, y[i]])
|
GR.polyline([x[i], x[i]], [ymin, y[i]])
|
||||||
end
|
end
|
||||||
legend = true
|
legend = true
|
||||||
elseif p[:linetype] == :scatter || p[:markershape] != :none
|
elseif p[:linetype] == :scatter || (p[:markershape] != :none && axes_2d)
|
||||||
haskey(p, :markercolor) && GR.setmarkercolorind(gr_getcolorind(p[:markercolor]))
|
haskey(p, :markercolor) && GR.setmarkercolorind(gr_getcolorind(p[:markercolor]))
|
||||||
haskey(p, :markershape) && GR.setmarkertype(gr_markertype[p[:markershape]])
|
haskey(p, :markershape) && GR.setmarkertype(gr_markertype[p[:markershape]])
|
||||||
if haskey(d, :markersize)
|
if haskey(d, :markersize)
|
||||||
@ -346,7 +346,7 @@ function gr_display(plt::Plot{GRPackage}, 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)
|
||||||
elseif p[:linetype] in [:surface, :wrireframe]
|
elseif p[:linetype] in [:surface, :wireframe]
|
||||||
x, y, z = p[:x], p[:y], p[:z].surf
|
x, y, z = p[:x], p[:y], p[:z].surf
|
||||||
zmin, zmax = GR.adjustrange(minimum(z), maximum(z))
|
zmin, zmax = GR.adjustrange(minimum(z), maximum(z))
|
||||||
GR.setspace(zmin, zmax, 40, 70)
|
GR.setspace(zmin, zmax, 40, 70)
|
||||||
@ -359,19 +359,47 @@ function gr_display(plt::Plot{GRPackage}, clear=true, update=true,
|
|||||||
GR.setcharheight(charheight)
|
GR.setcharheight(charheight)
|
||||||
GR.grid3d(xtick, 0, ztick, xmin, ymin, zmin, 2, 0, 2)
|
GR.grid3d(xtick, 0, ztick, xmin, ymin, zmin, 2, 0, 2)
|
||||||
GR.grid3d(0, ytick, 0, xmax, ymin, zmin, 0, 2, 0)
|
GR.grid3d(0, ytick, 0, xmax, ymin, zmin, 0, 2, 0)
|
||||||
GR.setcolormap(GR.COLORMAP_COOLWARM)
|
|
||||||
z = reshape(z, length(x) * length(y))
|
z = reshape(z, length(x) * length(y))
|
||||||
if p[:linetype] == :surface
|
if p[:linetype] == :surface
|
||||||
|
GR.setcolormap(GR.COLORMAP_COOLWARM)
|
||||||
GR.gr3.surface(x, y, z, GR.OPTION_COLORED_MESH)
|
GR.gr3.surface(x, y, z, GR.OPTION_COLORED_MESH)
|
||||||
else
|
else
|
||||||
GR.surface(x, y, z, GR.OPTION_MESH)
|
GR.setfillcolorind(0)
|
||||||
|
GR.surface(x, y, z, GR.OPTION_FILLED_MESH)
|
||||||
end
|
end
|
||||||
GR.axes3d(xtick, 0, ztick, xmin, ymin, zmin, 2, 0, 2, -ticksize)
|
GR.axes3d(xtick, 0, ztick, xmin, ymin, zmin, 2, 0, 2, -ticksize)
|
||||||
GR.axes3d(0, ytick, 0, xmax, ymin, zmin, 0, 2, 0, ticksize)
|
GR.axes3d(0, ytick, 0, xmax, ymin, zmin, 0, 2, 0, ticksize)
|
||||||
GR.setviewport(viewport[2] + 0.07, viewport[2] + 0.1,
|
if cmap
|
||||||
viewport[3], viewport[4])
|
GR.setviewport(viewport[2] + 0.07, viewport[2] + 0.1,
|
||||||
GR.colormap()
|
viewport[3], viewport[4])
|
||||||
elseif p[:linetype] in [:path3d, :scatter3d, :ohlc, :pie]
|
GR.colormap()
|
||||||
|
end
|
||||||
|
elseif p[:linetype] in [:path3d, :scatter3d]
|
||||||
|
x, y, z = p[:x], p[:y], p[:z]
|
||||||
|
zmin, zmax = GR.adjustrange(minimum(z), maximum(z))
|
||||||
|
GR.setspace(zmin, zmax, 40, 70)
|
||||||
|
xtick = GR.tick(xmin, xmax) / 2
|
||||||
|
ytick = GR.tick(ymin, ymax) / 2
|
||||||
|
ztick = GR.tick(zmin, zmax) / 2
|
||||||
|
diag = sqrt((viewport[2] - viewport[1])^2 + (viewport[4] - viewport[3])^2)
|
||||||
|
charheight = max(0.018 * diag, 0.01)
|
||||||
|
ticksize = 0.01 * (viewport[2] - viewport[1])
|
||||||
|
GR.setcharheight(charheight)
|
||||||
|
GR.grid3d(xtick, 0, ztick, xmin, ymin, zmin, 2, 0, 2)
|
||||||
|
GR.grid3d(0, ytick, 0, xmax, ymin, zmin, 0, 2, 0)
|
||||||
|
if p[:linetype] == :scatter3d
|
||||||
|
haskey(p, :markercolor) && GR.setmarkercolorind(gr_getcolorind(p[:markercolor]))
|
||||||
|
haskey(p, :markershape) && GR.setmarkertype(gr_markertype[p[:markershape]])
|
||||||
|
for i = 1:length(z)
|
||||||
|
px, py = GR.wc3towc(x[i], y[i], z[i])
|
||||||
|
GR.polymarker([px], [py])
|
||||||
|
end
|
||||||
|
else
|
||||||
|
GR.polyline3d(x, y, z)
|
||||||
|
end
|
||||||
|
GR.axes3d(xtick, 0, ztick, xmin, ymin, zmin, 2, 0, 2, -ticksize)
|
||||||
|
GR.axes3d(0, ytick, 0, xmax, ymin, zmin, 0, 2, 0, ticksize)
|
||||||
|
elseif p[:linetype] in [:ohlc, :pie]
|
||||||
println("TODO: add support for linetype $(p[:linetype])")
|
println("TODO: add support for linetype $(p[:linetype])")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user