GR fix handling of Shape; PyPlot marker colors fix (hack), closes #145
This commit is contained in:
parent
cdff5a9039
commit
9d3e0651e2
@ -19,6 +19,10 @@ const gr_markertype = Dict(
|
||||
:star4 => -25, :star5 => -26, :star6 => -27, :star7 => -28, :star8 => -29,
|
||||
:vline => -30, :hline => -31 )
|
||||
|
||||
set_gr_markertype(shape::Shape) = set_gr_markertype(:ellipse)
|
||||
set_gr_markertype(shape) = GR.setmarkertype(gr_markertype[shape])
|
||||
|
||||
|
||||
const gr_halign = Dict(:left => 1, :hcenter => 2, :right => 3)
|
||||
const gr_valign = Dict(:top => 1, :vcenter => 3, :bottom => 5)
|
||||
|
||||
@ -326,7 +330,7 @@ function gr_display(plt::Plot{GRPackage}, clear=true, update=true,
|
||||
legend = true
|
||||
elseif p[:linetype] == :scatter || (p[:markershape] != :none && axes_2d)
|
||||
haskey(p, :markercolor) && GR.setmarkercolorind(gr_getcolorind(p[:markercolor]))
|
||||
haskey(p, :markershape) && GR.setmarkertype(gr_markertype[p[:markershape]])
|
||||
haskey(p, :markershape) && set_gr_markertype(p[:markershape])
|
||||
if haskey(d, :markersize)
|
||||
if typeof(d[:markersize]) <: Number
|
||||
GR.setmarkersize(d[:markersize] / 4.0)
|
||||
@ -469,7 +473,7 @@ function gr_display(plt::Plot{GRPackage}, clear=true, update=true,
|
||||
end
|
||||
if p[:linetype] == :scatter3d
|
||||
haskey(p, :markercolor) && GR.setmarkercolorind(gr_getcolorind(p[:markercolor]))
|
||||
haskey(p, :markershape) && GR.setmarkertype(gr_markertype[p[:markershape]])
|
||||
haskey(p, :markershape) && set_gr_markertype(p[:markershape])
|
||||
for i = 1:length(z)
|
||||
px, py = GR.wc3towc(x[i], y[i], z[i])
|
||||
GR.polymarker([px], [py])
|
||||
@ -559,7 +563,7 @@ function gr_display(plt::Plot{GRPackage}, clear=true, update=true,
|
||||
end
|
||||
if p[:linetype] == :scatter || p[:markershape] != :none
|
||||
haskey(p, :markercolor) && GR.setmarkercolorind(gr_getcolorind(p[:markercolor]))
|
||||
haskey(p, :markershape) && GR.setmarkertype(gr_markertype[p[:markershape]])
|
||||
haskey(p, :markershape) && set_gr_markertype(p[:markershape])
|
||||
if p[:linetype] in [:path, :line, :steppre, :steppost, :sticks]
|
||||
GR.polymarker([px - 0.06, px - 0.02], [py, py])
|
||||
else
|
||||
|
||||
@ -350,7 +350,17 @@ function _add_series(pkg::PyPlotPackage, plt::Plot; kw...)
|
||||
extra_kwargs[:c] = convert(Vector{Float64}, d[:zcolor])
|
||||
extra_kwargs[:cmap] = getPyPlotColorMap(c, d[:markeralpha])
|
||||
else
|
||||
extra_kwargs[:c] = getPyPlotColor(c, d[:markeralpha])
|
||||
# extra_kwargs[:c] = getPyPlotColor(c, d[:markeralpha])
|
||||
ppc = getPyPlotColor(c, d[:markeralpha])
|
||||
|
||||
# total hack due to PyPlot bug (see issue #145).
|
||||
# hack: duplicate the color vector when the total rgba fields is the same as the series length
|
||||
if (typeof(ppc) <: AbstractArray && length(ppc)*4 == length(x)) ||
|
||||
(typeof(ppc) <: Tuple && length(x) == 4)
|
||||
ppc = vcat(ppc, ppc)
|
||||
end
|
||||
extra_kwargs[:c] = ppc
|
||||
|
||||
end
|
||||
if d[:markeralpha] != nothing
|
||||
extra_kwargs[:alpha] = d[:markeralpha]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user