Merge 14b856b0cf16ca973b743008dd32e4c9ad418657 into b6e627369b68418b1fb87108e127dc5d5e2a4821
This commit is contained in:
commit
6ff83583a7
@ -2,14 +2,35 @@
|
|||||||
# https://github.com/jheinen/GR.jl
|
# https://github.com/jheinen/GR.jl
|
||||||
|
|
||||||
const gr_linetype = Dict(
|
const gr_linetype = Dict(
|
||||||
:auto => 0, :solid => 1, :dash => 2, :dot => 3, :dashdot => 4,
|
:auto => 1, :solid => 1, :dash => 2, :dot => 3, :dashdot => 4,
|
||||||
:dashdotdot => -1 )
|
:dashdotdot => -1 )
|
||||||
|
|
||||||
const gr_markertype = Dict(
|
const gr_markertype = Dict(
|
||||||
:none => 1, :ellipse => -1, :rect => -7, :diamond => -13,
|
:auto => 1, :none => -1, :ellipse => -1, :rect => -7, :diamond => -13,
|
||||||
:utriangle => -3, :dtriangle => -5, :pentagon => -14,
|
:utriangle => -3, :dtriangle => -5, :pentagon => -14, :hexagon => 3,
|
||||||
:cross => 2, :xcross => 5, :star5 => 3 )
|
:cross => 2, :xcross => 5, :star5 => 3 )
|
||||||
|
|
||||||
|
const gr_halign = Dict(:left => 1, :hcenter => 2, :right => 3)
|
||||||
|
const gr_valign = Dict(:top => 1, :vcenter => 3, :bottom => 5)
|
||||||
|
|
||||||
|
const gr_font_family = Dict(
|
||||||
|
"times" => 1, "helvetica" => 5, "courier" => 9, "bookman" => 14,
|
||||||
|
"newcenturyschlbk" => 18, "avantgarde" => 22, "palatino" => 26)
|
||||||
|
|
||||||
|
function gr_getcolorind(v)
|
||||||
|
c = getColor(v)
|
||||||
|
return convert(Int, GR.inqcolorfromrgb(c.r, c.g, c.b))
|
||||||
|
end
|
||||||
|
|
||||||
|
function gr_getaxisind(p)
|
||||||
|
axis = get(p, :axis, :none)
|
||||||
|
if axis in [:none, :left]
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
return 2
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function gr_display(plt::Plot{GRPackage})
|
function gr_display(plt::Plot{GRPackage})
|
||||||
d = plt.plotargs
|
d = plt.plotargs
|
||||||
|
|
||||||
@ -31,17 +52,46 @@ function gr_display(plt::Plot{GRPackage})
|
|||||||
viewport = [0.1 * ratio, 0.95 * ratio, 0.1, 0.95]
|
viewport = [0.1 * ratio, 0.95 * ratio, 0.1, 0.95]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
extrema = zeros(2, 4)
|
||||||
|
num_axes = 1
|
||||||
|
|
||||||
|
for axis = 1:2
|
||||||
xmin = ymin = typemax(Float64)
|
xmin = ymin = typemax(Float64)
|
||||||
xmax = ymax = typemin(Float64)
|
xmax = ymax = typemin(Float64)
|
||||||
for p in plt.seriesargs
|
for p in plt.seriesargs
|
||||||
|
if axis == gr_getaxisind(p)
|
||||||
|
if axis == 2
|
||||||
|
num_axes = 2
|
||||||
|
end
|
||||||
|
if p[:linetype] == :bar
|
||||||
|
x, y = 1:length(p[:y]), p[:y]
|
||||||
|
elseif p[:linetype] == :hist
|
||||||
|
x, y = Base.hist(p[:y])
|
||||||
|
else
|
||||||
x, y = p[:x], p[:y]
|
x, y = p[:x], p[:y]
|
||||||
|
end
|
||||||
xmin = min(minimum(x), xmin)
|
xmin = min(minimum(x), xmin)
|
||||||
xmax = max(maximum(x), xmax)
|
xmax = max(maximum(x), xmax)
|
||||||
|
# catch exception for OHLC vectors
|
||||||
|
try
|
||||||
ymin = min(minimum(y), ymin)
|
ymin = min(minimum(y), ymin)
|
||||||
ymax = max(maximum(y), ymax)
|
ymax = max(maximum(y), ymax)
|
||||||
|
catch MethodError
|
||||||
|
ymin, ymax = 0, 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
extrema[axis,:] = [xmin, xmax, ymin, ymax]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if num_axes == 2
|
||||||
|
viewport[2] -= 0.05
|
||||||
|
end
|
||||||
|
GR.setviewport(viewport[1], viewport[2], viewport[3], viewport[4])
|
||||||
|
|
||||||
scale = d[:scale]
|
scale = d[:scale]
|
||||||
|
for axis = 1:num_axes
|
||||||
|
xmin, xmax, ymin, ymax = extrema[axis,:]
|
||||||
if scale & GR.OPTION_X_LOG == 0
|
if scale & GR.OPTION_X_LOG == 0
|
||||||
xmin, xmax = GR.adjustlimits(xmin, xmax)
|
xmin, xmax = GR.adjustlimits(xmin, xmax)
|
||||||
majorx = 5
|
majorx = 5
|
||||||
@ -67,59 +117,180 @@ function gr_display(plt::Plot{GRPackage})
|
|||||||
yorg = (ymax, ymin)
|
yorg = (ymax, ymin)
|
||||||
end
|
end
|
||||||
|
|
||||||
GR.setviewport(viewport[1], viewport[2], viewport[3], viewport[4])
|
|
||||||
GR.setwindow(xmin, xmax, ymin, ymax)
|
GR.setwindow(xmin, xmax, ymin, ymax)
|
||||||
|
if axis == 1 && haskey(d, :background_color)
|
||||||
|
GR.savestate()
|
||||||
|
GR.setfillintstyle(GR.INTSTYLE_SOLID)
|
||||||
|
GR.setfillcolorind(gr_getcolorind(d[:background_color]))
|
||||||
|
GR.fillrect(xmin, xmax, ymin, ymax)
|
||||||
|
GR.restorestate()
|
||||||
|
end
|
||||||
GR.setscale(scale)
|
GR.setscale(scale)
|
||||||
|
|
||||||
charheight = 0.03 * (viewport[4] - viewport[3])
|
charheight = 0.03 * (viewport[4] - viewport[3])
|
||||||
GR.setcharheight(charheight)
|
GR.setcharheight(charheight)
|
||||||
GR.grid(xtick, ytick, 0, 0, majorx, majory)
|
GR.grid(xtick, ytick, 0, 0, majorx, majory)
|
||||||
ticksize = 0.0125 * (viewport[2] - viewport[1])
|
ticksize = 0.0125 * (viewport[2] - viewport[1])
|
||||||
|
if num_axes == 1
|
||||||
GR.axes(xtick, ytick, xorg[1], yorg[1], majorx, majory, ticksize)
|
GR.axes(xtick, ytick, xorg[1], yorg[1], majorx, majory, ticksize)
|
||||||
GR.axes(xtick, ytick, xorg[2], yorg[2], -majorx, -majory, -ticksize)
|
GR.axes(xtick, ytick, xorg[2], yorg[2], -majorx, -majory, -ticksize)
|
||||||
|
elseif axis == 1
|
||||||
|
GR.axes(xtick, ytick, xorg[1], yorg[1], majorx, majory, ticksize)
|
||||||
|
else
|
||||||
|
GR.axes(xtick, ytick, xorg[2], yorg[2], -majorx, majory, -ticksize)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if haskey(d, :title)
|
if get(d, :title, "") != ""
|
||||||
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.text(0.5, min(ratio, 1), d[:title])
|
GR.text(0.5, min(ratio, 1), d[:title])
|
||||||
GR.restorestate()
|
GR.restorestate()
|
||||||
end
|
end
|
||||||
if haskey(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.text(0.5, 0, d[:xlabel])
|
GR.text(0.5, 0, d[:xlabel])
|
||||||
GR.restorestate()
|
GR.restorestate()
|
||||||
end
|
end
|
||||||
if haskey(d, :ylabel)
|
if get(d, :ylabel, "") != ""
|
||||||
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.setcharup(-1, 0)
|
GR.setcharup(-1, 0)
|
||||||
GR.text(0, 0.5 * (viewport[3] + viewport[4]), d[:ylabel])
|
GR.text(0, 0.5 * (viewport[3] + viewport[4]), d[:ylabel])
|
||||||
GR.restorestate()
|
GR.restorestate()
|
||||||
end
|
end
|
||||||
|
if get(d, :yrightlabel, "") != ""
|
||||||
|
GR.savestate()
|
||||||
|
GR.settextalign(GR.TEXT_HALIGN_CENTER, GR.TEXT_VALIGN_TOP)
|
||||||
|
GR.setcharup(1, 0)
|
||||||
|
GR.text(1, 0.5 * (viewport[3] + viewport[4]), d[:yrightlabel])
|
||||||
|
GR.restorestate()
|
||||||
|
end
|
||||||
|
|
||||||
GR.savestate()
|
GR.savestate()
|
||||||
haskey(d, :linewidth) && GR.setlinewidth(d[:linewidth])
|
haskey(d, :linewidth) && GR.setlinewidth(d[:linewidth])
|
||||||
haskey(d, :linestyle) && GR.setlinetype(gr_linetype[d[:linestyle]])
|
|
||||||
haskey(d, :markersize) && GR.setmarkersize(d[:markersize])
|
|
||||||
haskey(d, :markershape) && GR.setmarkertype(gr_markertype[d[:markershape]])
|
|
||||||
GR.settextalign(GR.TEXT_HALIGN_LEFT, GR.TEXT_VALIGN_HALF)
|
GR.settextalign(GR.TEXT_HALIGN_LEFT, GR.TEXT_VALIGN_HALF)
|
||||||
|
|
||||||
|
legend = false
|
||||||
|
|
||||||
for p in plt.seriesargs
|
for p in plt.seriesargs
|
||||||
GR.uselinespec("")
|
xmin, xmax, ymin, ymax = extrema[gr_getaxisind(p),:]
|
||||||
|
GR.setwindow(xmin, xmax, ymin, ymax)
|
||||||
|
if p[:linetype] in [:path, :line, :steppre, :steppost, :sticks, :hline, :vline]
|
||||||
|
haskey(p, :linecolor) && GR.setlinecolorind(gr_getcolorind(p[:linecolor]))
|
||||||
|
haskey(p, :linestyle) && GR.setlinetype(gr_linetype[p[:linestyle]])
|
||||||
|
end
|
||||||
if p[:linetype] == :path
|
if p[:linetype] == :path
|
||||||
|
if haskey(p, :fillcolor)
|
||||||
|
GR.setfillcolorind(gr_getcolorind(p[:fillcolor]))
|
||||||
|
GR.setfillintstyle(GR.INTSTYLE_SOLID)
|
||||||
|
end
|
||||||
|
if p[:fillrange] != nothing
|
||||||
|
GR.fillarea([p[:x][1]; p[:x]; p[:x][length(p[:x])]], [p[:fillrange]; p[:y]; p[:fillrange]])
|
||||||
|
end
|
||||||
GR.polyline(p[:x], p[:y])
|
GR.polyline(p[:x], p[:y])
|
||||||
elseif p[:linetype] == :scatter
|
legend = true
|
||||||
|
end
|
||||||
|
if p[:linetype] == :line
|
||||||
|
GR.polyline(p[:x], p[:y])
|
||||||
|
legend = true
|
||||||
|
elseif p[:linetype] in [:steppre, :steppost]
|
||||||
|
n = length(p[:x])
|
||||||
|
x = zeros(2*n + 1)
|
||||||
|
y = zeros(2*n + 1)
|
||||||
|
x[1], y[1] = p[:x][1], p[:y][1]
|
||||||
|
j = 2
|
||||||
|
for i = 2:n
|
||||||
|
if p[:linetype] == :steppre
|
||||||
|
x[j], x[j+1] = p[:x][i-1], p[:x][i]
|
||||||
|
y[j], y[j+1] = p[:y][i], p[:y][i]
|
||||||
|
else
|
||||||
|
x[j], x[j+1] = p[:x][i], p[:x][i]
|
||||||
|
y[j], y[j+1] = p[:y][i-1], p[:y][i]
|
||||||
|
end
|
||||||
|
j += 2
|
||||||
|
end
|
||||||
|
GR.polyline(x, y)
|
||||||
|
legend = true
|
||||||
|
elseif p[:linetype] == :sticks
|
||||||
|
x, y = p[:x], p[:y]
|
||||||
|
for i = 1:length(y)
|
||||||
|
GR.polyline([x[i], x[i]], [ymin, y[i]])
|
||||||
|
end
|
||||||
|
legend = true
|
||||||
|
elseif p[:linetype] == :scatter || p[:markershape] != :none
|
||||||
|
haskey(p, :markercolor) && GR.setmarkercolorind(gr_getcolorind(p[:markercolor]))
|
||||||
|
haskey(p, :markershape) && GR.setmarkertype(gr_markertype[p[:markershape]])
|
||||||
|
if haskey(d, :markersize)
|
||||||
|
if typeof(d[:markersize]) <: Number
|
||||||
|
GR.setmarkersize(d[:markersize] / 4.0)
|
||||||
GR.polymarker(p[:x], p[:y])
|
GR.polymarker(p[:x], p[:y])
|
||||||
|
else
|
||||||
|
c = p[:markercolor]
|
||||||
|
GR.setcolormap(-GR.COLORMAP_GLOWING)
|
||||||
|
for i = 1:length(p[:x])
|
||||||
|
if isa(c, ColorGradient) && p[:zcolor] != nothing
|
||||||
|
ci = round(Int, 1000 + p[:zcolor][i] * 255)
|
||||||
|
GR.setmarkercolorind(ci)
|
||||||
|
end
|
||||||
|
GR.setmarkersize(d[:markersize][i] / 4.0)
|
||||||
|
GR.polymarker([p[:x][i]], [p[:y][i]])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
GR.polymarker(p[:x], p[:y])
|
||||||
|
end
|
||||||
|
legend = true
|
||||||
|
elseif p[:linetype] == :bar
|
||||||
|
y = p[:y]
|
||||||
|
for i = 1:length(y)
|
||||||
|
GR.setfillcolorind(gr_getcolorind(p[:fillcolor]))
|
||||||
|
GR.setfillintstyle(GR.INTSTYLE_SOLID)
|
||||||
|
GR.fillrect(i-0.4, i+0.4, max(0, ymin), y[i])
|
||||||
|
GR.setfillcolorind(1)
|
||||||
|
GR.setfillintstyle(GR.INTSTYLE_HOLLOW)
|
||||||
|
GR.fillrect(i-0.4, i+0.4, max(0, ymin), y[i])
|
||||||
|
end
|
||||||
|
elseif p[:linetype] == :hist
|
||||||
|
h = Base.hist(p[:y])
|
||||||
|
x, y = float(collect(h[1])), float(h[2])
|
||||||
|
for i = 2:length(y)
|
||||||
|
GR.setfillcolorind(gr_getcolorind(p[:fillcolor]))
|
||||||
|
GR.setfillintstyle(GR.INTSTYLE_SOLID)
|
||||||
|
GR.fillrect(x[i-1], x[i], ymin, y[i])
|
||||||
|
GR.setfillcolorind(1)
|
||||||
|
GR.setfillintstyle(GR.INTSTYLE_HOLLOW)
|
||||||
|
GR.fillrect(x[i-1], x[i], ymin, y[i])
|
||||||
|
end
|
||||||
|
elseif p[:linetype] in [:hline, :vline]
|
||||||
|
for xy in p[:y]
|
||||||
|
if p[:linetype] == :hline
|
||||||
|
GR.polyline([xmin, xmax], [xy, xy])
|
||||||
|
else
|
||||||
|
GR.polyline([xy, xy], [ymin, ymax])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
elseif p[:linetype] in [:heatmap, :hexbin, :density,
|
||||||
|
:contour, :path3d, :scatter3d, :surface,
|
||||||
|
:wireframe, :ohlc, :pie]
|
||||||
|
println("TODO: add support for linetype $(p[:linetype])")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if d[:legend]
|
if d[:legend] && legend
|
||||||
GR.selntran(0)
|
GR.selntran(0)
|
||||||
GR.setscale(0)
|
GR.setscale(0)
|
||||||
w = 0
|
w = 0
|
||||||
|
i = 0
|
||||||
for p in plt.seriesargs
|
for p in plt.seriesargs
|
||||||
tbx, tby = GR.inqtext(0, 0, p[:label])
|
if typeof(p[:label]) <: Array
|
||||||
|
i += 1
|
||||||
|
lab = p[:label][i]
|
||||||
|
else
|
||||||
|
lab = p[:label]
|
||||||
|
end
|
||||||
|
tbx, tby = GR.inqtext(0, 0, lab)
|
||||||
w = max(w, tbx[3])
|
w = max(w, tbx[3])
|
||||||
end
|
end
|
||||||
px = viewport[2] - 0.05 - w
|
px = viewport[2] - 0.05 - w
|
||||||
@ -127,28 +298,60 @@ function gr_display(plt::Plot{GRPackage})
|
|||||||
GR.setfillintstyle(GR.INTSTYLE_SOLID)
|
GR.setfillintstyle(GR.INTSTYLE_SOLID)
|
||||||
GR.setfillcolorind(0)
|
GR.setfillcolorind(0)
|
||||||
GR.fillrect(px - 0.06, px + w + 0.02, py + 0.03, py - 0.03 * length(plt.seriesargs))
|
GR.fillrect(px - 0.06, px + w + 0.02, py + 0.03, py - 0.03 * length(plt.seriesargs))
|
||||||
|
GR.setlinetype(1)
|
||||||
GR.setlinecolorind(1)
|
GR.setlinecolorind(1)
|
||||||
GR.setlinewidth(1)
|
GR.setlinewidth(1)
|
||||||
GR.drawrect(px - 0.06, px + w + 0.02, py + 0.03, py - 0.03 * length(plt.seriesargs))
|
GR.drawrect(px - 0.06, px + w + 0.02, py + 0.03, py - 0.03 * length(plt.seriesargs))
|
||||||
haskey(d, :linewidth) && GR.setlinewidth(d[:linewidth])
|
haskey(d, :linewidth) && GR.setlinewidth(d[:linewidth])
|
||||||
|
i = 0
|
||||||
for p in plt.seriesargs
|
for p in plt.seriesargs
|
||||||
GR.uselinespec("")
|
if p[:linetype] in [:path, :line, :steppre, :steppost, :sticks]
|
||||||
if p[:linetype] == :path
|
haskey(p, :linecolor) && GR.setlinecolorind(gr_getcolorind(p[:linecolor]))
|
||||||
|
haskey(p, :linestyle) && GR.setlinetype(gr_linetype[p[:linestyle]])
|
||||||
GR.polyline([px - 0.05, px - 0.01], [py, py])
|
GR.polyline([px - 0.05, px - 0.01], [py, py])
|
||||||
elseif p[:linetype] == :scatter
|
|
||||||
GR.polymarker([px - 0.05, px - 0.01], [py, py])
|
|
||||||
end
|
end
|
||||||
GR.text(px, py, p[:label])
|
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]])
|
||||||
|
GR.polymarker([px - 0.04, px - 0.02], [py, py])
|
||||||
|
end
|
||||||
|
if typeof(p[:label]) <: Array
|
||||||
|
i += 1
|
||||||
|
lab = p[:label][i]
|
||||||
|
else
|
||||||
|
lab = p[:label]
|
||||||
|
end
|
||||||
|
GR.text(px, py, lab)
|
||||||
py -= 0.03
|
py -= 0.03
|
||||||
end
|
end
|
||||||
GR.selntran(1)
|
GR.selntran(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
GR.restorestate()
|
GR.restorestate()
|
||||||
|
|
||||||
|
if haskey(d, :anns)
|
||||||
|
GR.savestate()
|
||||||
|
for ann in d[:anns]
|
||||||
|
x, y, val = ann
|
||||||
|
x, y = GR.wctondc(x, y)
|
||||||
|
alpha = val.font.rotation
|
||||||
|
family = lowercase(val.font.family)
|
||||||
|
GR.setcharheight(0.7 * val.font.pointsize / d[:size][2])
|
||||||
|
GR.setcharup(sin(val.font.rotation), cos(val.font.rotation))
|
||||||
|
if haskey(gr_font_family, family)
|
||||||
|
GR.settextfontprec(100 + gr_font_family[family], GR.TEXT_PRECISION_STRING)
|
||||||
|
end
|
||||||
|
GR.settextcolorind(gr_getcolorind(val.font.color))
|
||||||
|
GR.settextalign(gr_halign[val.font.halign], gr_valign[val.font.valign])
|
||||||
|
GR.text(x, y, val.str)
|
||||||
|
end
|
||||||
|
GR.restorestate()
|
||||||
|
end
|
||||||
|
|
||||||
GR.updatews()
|
GR.updatews()
|
||||||
end
|
end
|
||||||
|
|
||||||
function _create_plot(pkg::GRPackage; kw...)
|
function _create_plot(pkg::GRPackage; kw...)
|
||||||
|
isijulia() && GR.inline("png")
|
||||||
d = Dict(kw)
|
d = Dict(kw)
|
||||||
Plot(nothing, pkg, 0, d, Dict[])
|
Plot(nothing, pkg, 0, d, Dict[])
|
||||||
end
|
end
|
||||||
@ -160,8 +363,10 @@ function _add_series(::GRPackage, plt::Plot; kw...)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function _add_annotations{X,Y,V}(plt::Plot{GRPackage}, anns::AVec{@compat(Tuple{X,Y,V})})
|
function _add_annotations{X,Y,V}(plt::Plot{GRPackage}, anns::AVec{@compat(Tuple{X,Y,V})})
|
||||||
for ann in anns
|
if haskey(plt.plotargs, :anns)
|
||||||
# TODO: add the annotation to the plot
|
append!(plt.plotargs[:anns], anns)
|
||||||
|
else
|
||||||
|
plt.plotargs[:anns] = anns
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -178,7 +383,7 @@ function _update_plot(plt::Plot{GRPackage}, d::Dict)
|
|||||||
get(d, :yflip, false) && (scale |= GR.OPTION_FLIP_Y)
|
get(d, :yflip, false) && (scale |= GR.OPTION_FLIP_Y)
|
||||||
plt.plotargs[:scale] = scale
|
plt.plotargs[:scale] = scale
|
||||||
|
|
||||||
for k in (:title, :xlabel, :ylabel, :linewidth, :linestyle, :markersize, :markershape)
|
for k in (:title, :xlabel, :ylabel)
|
||||||
haskey(d, k) && (plt.plotargs[k] = d[k])
|
haskey(d, k) && (plt.plotargs[k] = d[k])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -188,16 +393,14 @@ end
|
|||||||
|
|
||||||
# ----------------------------------------------------------------
|
# ----------------------------------------------------------------
|
||||||
|
|
||||||
# accessors for x/y data
|
|
||||||
|
|
||||||
function Base.getindex(plt::Plot{GRPackage}, i::Int)
|
function Base.getindex(plt::Plot{GRPackage}, i::Int)
|
||||||
series = plt.o.lines[i]
|
d = plt.seriesargs[i]
|
||||||
series.x, series.y
|
d[:x], d[:y]
|
||||||
end
|
end
|
||||||
|
|
||||||
function Base.setindex!(plt::Plot{GRPackage}, xy::Tuple, i::Integer)
|
function Base.setindex!(plt::Plot{GRPackage}, xy::Tuple, i::Integer)
|
||||||
series = plt.o.lines[i]
|
d = plt.seriesargs[i]
|
||||||
series.x, series.y = xy
|
d[:x], d[:y] = xy
|
||||||
plt
|
plt
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -205,6 +408,7 @@ end
|
|||||||
|
|
||||||
function _create_subplot(subplt::Subplot{GRPackage}, isbefore::Bool)
|
function _create_subplot(subplt::Subplot{GRPackage}, isbefore::Bool)
|
||||||
# TODO: build the underlying Subplot object. this is where you might layout the panes within a GUI window, for example
|
# TODO: build the underlying Subplot object. this is where you might layout the panes within a GUI window, for example
|
||||||
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
function _expand_limits(lims, plt::Plot{GRPackage}, isx::Bool)
|
function _expand_limits(lims, plt::Plot{GRPackage}, isx::Bool)
|
||||||
@ -217,8 +421,11 @@ end
|
|||||||
|
|
||||||
# ----------------------------------------------------------------
|
# ----------------------------------------------------------------
|
||||||
|
|
||||||
function Base.writemime(io::IO, ::MIME"image/png", plt::PlottingObject{GRPackage})
|
function Base.writemime(io::IO, m::MIME"image/png", plt::PlottingObject{GRPackage})
|
||||||
# TODO: write a png to io
|
isijulia() || return
|
||||||
|
gr_display(plt)
|
||||||
|
GR.emergencyclosegks()
|
||||||
|
write(io, readall("gks.png"))
|
||||||
end
|
end
|
||||||
|
|
||||||
function Base.display(::PlotsDisplay, plt::Plot{GRPackage})
|
function Base.display(::PlotsDisplay, plt::Plot{GRPackage})
|
||||||
|
|||||||
@ -235,9 +235,10 @@ supportedArgs(::GRPackage) = [
|
|||||||
supportedAxes(::GRPackage) = _allAxes
|
supportedAxes(::GRPackage) = _allAxes
|
||||||
supportedTypes(::GRPackage) = [:none, :line, :path, :steppre, :steppost, :sticks,
|
supportedTypes(::GRPackage) = [:none, :line, :path, :steppre, :steppost, :sticks,
|
||||||
:scatter, :heatmap, :hexbin, :hist, :density, :bar,
|
:scatter, :heatmap, :hexbin, :hist, :density, :bar,
|
||||||
:hline, :vline, :contour, :path3d, :scatter3d, :surface, :wireframe]
|
:hline, :vline, :contour, :path3d, :scatter3d, :surface,
|
||||||
|
:wireframe, :ohlc, :pie]
|
||||||
supportedStyles(::GRPackage) = [:auto, :solid, :dash, :dot, :dashdot]
|
supportedStyles(::GRPackage) = [:auto, :solid, :dash, :dot, :dashdot]
|
||||||
supportedMarkers(::GRPackage) = [:none, :ellipse, :rect, :diamond, :utriangle, :dtriangle, :pentagon, :cross, :xcross, :star5]
|
supportedMarkers(::GRPackage) = vcat([:none, :ellipse, :rect, :diamond, :utriangle, :dtriangle, :pentagon, :hexagon, :cross, :xcross, :star5], Shape)
|
||||||
supportedScales(::GRPackage) = [:identity, :log10]
|
supportedScales(::GRPackage) = [:identity, :log10]
|
||||||
subplotSupported(::GRPackage) = true
|
subplotSupported(::GRPackage) = true
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user