Added support for legends
This commit is contained in:
parent
b0b2e695e1
commit
fd88972380
@ -147,24 +147,37 @@ function _update_plot(plt::Plot{GRPackage}, d::Dict)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
px = viewport[2] - 0.15
|
if plt.plotargs[:legend]
|
||||||
py = viewport[4] - 0.15
|
GR.selntran(0)
|
||||||
GR.selntran(0)
|
GR.setscale(0)
|
||||||
GR.setscale(0)
|
w = 0
|
||||||
for p in plt.seriesargs
|
for p in plt.seriesargs
|
||||||
GR.uselinespec("")
|
tbx, tby = GR.inqtext(0, 0, p[:label])
|
||||||
if p[:linetype] == :path
|
w = max(w, tbx[3])
|
||||||
GR.polyline([px, px + 0.04], [py, py])
|
|
||||||
elseif p[:linetype] == :scatter
|
|
||||||
GR.polymarker([px, px + 0.02], [py, py])
|
|
||||||
end
|
end
|
||||||
GR.text(px + 0.05, py, p[:label])
|
px = viewport[2] - 0.05 - w
|
||||||
py -= 0.03
|
py = viewport[4] - 0.06
|
||||||
|
GR.setfillintstyle(GR.INTSTYLE_SOLID)
|
||||||
|
GR.setfillcolorind(0)
|
||||||
|
GR.fillrect(px - 0.06, px + w + 0.02, py + 0.03, py - 0.03 * length(plt.seriesargs))
|
||||||
|
GR.setlinecolorind(1)
|
||||||
|
GR.setlinewidth(1)
|
||||||
|
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])
|
||||||
|
for p in plt.seriesargs
|
||||||
|
GR.uselinespec("")
|
||||||
|
if p[:linetype] == :path
|
||||||
|
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
|
||||||
|
GR.text(px, py, p[:label])
|
||||||
|
py -= 0.03
|
||||||
|
end
|
||||||
|
GR.selntran(1)
|
||||||
end
|
end
|
||||||
GR.selntran(1)
|
|
||||||
|
|
||||||
GR.restorestate()
|
GR.restorestate()
|
||||||
|
|
||||||
GR.updatews()
|
GR.updatews()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user