fixes for gr markers; add cbar to example 24; turn on gr tests
This commit is contained in:
parent
60d97ad9c9
commit
990314cefc
@ -312,28 +312,45 @@ function gr_fillrect(series::Series, l, r, b, t)
|
|||||||
GR.fillrect(l, r, b, t)
|
GR.fillrect(l, r, b, t)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
normalize_zvals(zv::Void) = zv
|
||||||
|
function normalize_zvals(zv::AVec)
|
||||||
|
vmin, vmax = extrema(zv)
|
||||||
|
if vmin == vmax
|
||||||
|
zeros(length(zv))
|
||||||
|
else
|
||||||
|
(zv - vmin) ./ (vmax - vmin)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function gr_draw_markers(series::Series, x = series.d[:x], y = series.d[:y])
|
function gr_draw_markers(series::Series, x = series.d[:x], y = series.d[:y])
|
||||||
d = series.d
|
d = series.d
|
||||||
msize = 0.5 * d[:markersize]
|
msize = 0.5 * d[:markersize]
|
||||||
|
mz = normalize_zvals(d[:marker_z])
|
||||||
GR.setmarkercolorind(gr_getcolorind(d[:markercolor]))
|
GR.setmarkercolorind(gr_getcolorind(d[:markercolor]))
|
||||||
gr_setmarkershape(d)
|
gr_setmarkershape(d)
|
||||||
if typeof(msize) <: Number
|
if typeof(msize) <: Number && mz == nothing
|
||||||
GR.setmarkersize(msize)
|
GR.setmarkersize(msize)
|
||||||
if length(x) > 0
|
if length(x) > 0
|
||||||
gr_polymarker(d, x, y)
|
gr_polymarker(d, x, y)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
c = d[:markercolor]
|
c = d[:markercolor]
|
||||||
GR.setcolormap(-GR.COLORMAP_GLOWING)
|
# GR.setcolormap(-GR.COLORMAP_GLOWING)
|
||||||
for i = 1:length(x)
|
for i = 1:length(x)
|
||||||
if isa(c, ColorGradient) && d[:marker_z] != nothing
|
if isa(c, ColorGradient) && mz != nothing
|
||||||
ci = round(Int, 1000 + d[:marker_z][i] * 255)
|
ci = round(Int, 1000 + mz[i] * 255)
|
||||||
GR.setmarkercolorind(ci)
|
GR.setmarkercolorind(ci)
|
||||||
end
|
end
|
||||||
GR.setmarkersize(msize[i])
|
GR.setmarkersize(isa(msize, Number) ? msize : msize[mod1(i, length(msize))])
|
||||||
gr_polymarker(d, [x[i]], [y[i]])
|
gr_polymarker(d, [x[i]], [y[i]])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if mz != nothing && d[:subplot][:colorbar] != :none
|
||||||
|
GR.setviewport(viewport_plotarea[2] + 0.02, viewport_plotarea[2] + 0.05, viewport_plotarea[3], viewport_plotarea[4])
|
||||||
|
GR.colormap()
|
||||||
|
GR.setviewport(viewport_plotarea[1], viewport_plotarea[2], viewport_plotarea[3], viewport_plotarea[4])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# function gr_barplot(series::Series, x, y)
|
# function gr_barplot(series::Series, x, y)
|
||||||
@ -396,6 +413,8 @@ end
|
|||||||
# mms ./ Float64[figw.value, figh.value, figw.value, figh.value]
|
# mms ./ Float64[figw.value, figh.value, figw.value, figh.value]
|
||||||
# end
|
# end
|
||||||
|
|
||||||
|
const viewport_plotarea = zeros(4)
|
||||||
|
|
||||||
function gr_viewport_from_bbox(bb::BoundingBox, w, h, viewport_canvas)
|
function gr_viewport_from_bbox(bb::BoundingBox, w, h, viewport_canvas)
|
||||||
viewport = zeros(4)
|
viewport = zeros(4)
|
||||||
viewport[1] = viewport_canvas[2] * (left(bb) / w)
|
viewport[1] = viewport_canvas[2] * (left(bb) / w)
|
||||||
@ -461,7 +480,7 @@ end
|
|||||||
function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
||||||
# the viewports for this subplot
|
# the viewports for this subplot
|
||||||
viewport_subplot = gr_viewport_from_bbox(bbox(sp), w, h, viewport_canvas)
|
viewport_subplot = gr_viewport_from_bbox(bbox(sp), w, h, viewport_canvas)
|
||||||
viewport_plotarea = gr_viewport_from_bbox(plotarea(sp), w, h, viewport_canvas)
|
viewport_plotarea[:] = gr_viewport_from_bbox(plotarea(sp), w, h, viewport_canvas)
|
||||||
# @show "SUBPLOT",sp[:subplot_index] bbox(sp) plotarea(sp) viewport_subplot viewport_plotarea
|
# @show "SUBPLOT",sp[:subplot_index] bbox(sp) plotarea(sp) viewport_subplot viewport_plotarea
|
||||||
|
|
||||||
# fill in the plot area background
|
# fill in the plot area background
|
||||||
@ -550,7 +569,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
axes_2d = true
|
axes_2d = true
|
||||||
for series in series_list(sp)
|
for series in series_list(sp)
|
||||||
st = ispolar(sp) ? :polar : series.d[:seriestype]
|
st = ispolar(sp) ? :polar : series.d[:seriestype]
|
||||||
if st in (:histogram2d, :hexbin, :contour, :surface, :heatmap)
|
if st in (:histogram2d, :hexbin, :contour, :surface, :heatmap) || series.d[:marker_z] != nothing
|
||||||
cmap = true
|
cmap = true
|
||||||
end
|
end
|
||||||
if st in (:pie, :polar, :surface, :wireframe, :path3d, :scatter3d)
|
if st in (:pie, :polar, :surface, :wireframe, :path3d, :scatter3d)
|
||||||
@ -809,6 +828,8 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
# GR.setcolorrep(999+i, red(c), green(c), blue(c))
|
# GR.setcolorrep(999+i, red(c), green(c), blue(c))
|
||||||
# end
|
# end
|
||||||
gr_set_gradient(d[:fillcolor])
|
gr_set_gradient(d[:fillcolor])
|
||||||
|
elseif d[:marker_z] != nothing
|
||||||
|
gr_set_gradient(d[:markercolor])
|
||||||
end
|
end
|
||||||
# if get(d, :polar, false)
|
# if get(d, :polar, false)
|
||||||
# st = :polar
|
# st = :polar
|
||||||
@ -1071,9 +1092,10 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
GR.setviewport(viewport_plotarea[1], viewport_plotarea[2], viewport_plotarea[3], viewport_plotarea[4])
|
GR.setviewport(viewport_plotarea[1], viewport_plotarea[2], viewport_plotarea[3], viewport_plotarea[4])
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif st in [:path3d, :scatter3d]
|
elseif st in (:path3d, :scatter3d)
|
||||||
x, y, z = d[:x], d[:y], d[:z]
|
x, y, z = d[:x], d[:y], d[:z]
|
||||||
# zmin, zmax = gr_getzlims(d, minimum(z), maximum(z), true)
|
|
||||||
|
# first set up the 3D axes
|
||||||
zmin, zmax = gr_lims(zaxis, true)
|
zmin, zmax = gr_lims(zaxis, true)
|
||||||
GR.setspace(zmin, zmax, 40, 70)
|
GR.setspace(zmin, zmax, 40, 70)
|
||||||
xtick = GR.tick(xmin, xmax) / 2
|
xtick = GR.tick(xmin, xmax) / 2
|
||||||
@ -1083,27 +1105,34 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
# charheight = max(0.018 * window_diag, 0.01)
|
# charheight = max(0.018 * window_diag, 0.01)
|
||||||
ticksize = 0.01 * (viewport_plotarea[2] - viewport_plotarea[1])
|
ticksize = 0.01 * (viewport_plotarea[2] - viewport_plotarea[1])
|
||||||
GR.setlinewidth(1)
|
GR.setlinewidth(1)
|
||||||
if grid_flag && st == :path3d
|
if grid_flag
|
||||||
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)
|
||||||
end
|
end
|
||||||
if st == :scatter3d
|
GR.axes3d(xtick, 0, ztick, xmin, ymin, zmin, 2, 0, 2, -ticksize)
|
||||||
GR.setmarkercolorind(gr_getcolorind(d[:markercolor]))
|
GR.axes3d(0, ytick, 0, xmax, ymin, zmin, 0, 2, 0, ticksize)
|
||||||
gr_setmarkershape(d)
|
|
||||||
for i = 1:length(z)
|
# draw path
|
||||||
xi, yi = GR.wc3towc(x[i], y[i], z[i])
|
if st == :path3d
|
||||||
gr_polymarker(d, [xi], [yi])
|
|
||||||
end
|
|
||||||
else
|
|
||||||
if length(x) > 0
|
if length(x) > 0
|
||||||
GR.setlinewidth(d[:linewidth])
|
GR.setlinewidth(d[:linewidth])
|
||||||
GR.polyline3d(x, y, z)
|
GR.polyline3d(x, y, z)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
GR.setlinewidth(1)
|
|
||||||
# GR.setcharheight(charheight)
|
# draw markers
|
||||||
GR.axes3d(xtick, 0, ztick, xmin, ymin, zmin, 2, 0, 2, -ticksize)
|
if st == :scatter3d || d[:markershape] != :none
|
||||||
GR.axes3d(0, ytick, 0, xmax, ymin, zmin, 0, 2, 0, ticksize)
|
x2, y2 = unzip(map(GR.wc3towc, x, y, z))
|
||||||
|
gr_draw_markers(series, x2, y2)
|
||||||
|
# GR.setmarkercolorind(gr_getcolorind(d[:markercolor]))
|
||||||
|
# gr_setmarkershape(d)
|
||||||
|
# for i = 1:length(z)
|
||||||
|
# xi, yi = GR.wc3towc(x[i], y[i], z[i])
|
||||||
|
# gr_polymarker(d, [xi], [yi])
|
||||||
|
# end
|
||||||
|
end
|
||||||
|
# GR.setlinewidth(1)
|
||||||
|
# # GR.setcharheight(charheight)
|
||||||
|
|
||||||
elseif st == :pie
|
elseif st == :pie
|
||||||
GR.selntran(0)
|
GR.selntran(0)
|
||||||
|
|||||||
@ -258,7 +258,7 @@ PlotExample("3D",
|
|||||||
x = ts .* map(cos,ts)
|
x = ts .* map(cos,ts)
|
||||||
y = 0.1ts .* map(sin,ts)
|
y = 0.1ts .* map(sin,ts)
|
||||||
z = 1:n
|
z = 1:n
|
||||||
plot(x, y, z, zcolor=reverse(z), m=(10,0.8,:blues,stroke(0)), leg=false, w=5)
|
plot(x, y, z, zcolor=reverse(z), m=(10,0.8,:blues,stroke(0)), leg=false, cbar=true, w=5)
|
||||||
plot!(zeros(n),zeros(n),1:n, w=10)
|
plot!(zeros(n),zeros(n),1:n, w=10)
|
||||||
end)]
|
end)]
|
||||||
),
|
),
|
||||||
|
|||||||
@ -30,7 +30,7 @@ facts("GR") do
|
|||||||
@fact gr() --> Plots.GRBackend()
|
@fact gr() --> Plots.GRBackend()
|
||||||
@fact backend() --> Plots.GRBackend()
|
@fact backend() --> Plots.GRBackend()
|
||||||
|
|
||||||
# @linux_only image_comparison_facts(:gr, skip=[6,24], eps=img_eps)
|
@linux_only image_comparison_facts(:gr, eps=img_eps)
|
||||||
end
|
end
|
||||||
|
|
||||||
facts("Plotly") do
|
facts("Plotly") do
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user