-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,12 +2,12 @@ | |
# https://github.com/jheinen/GR.jl | ||
|
||
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 ) | ||
|
||
const gr_markertype = Dict( | ||
:none => 1, :ellipse => -1, :rect => -7, :diamond => -13, | ||
:utriangle => -3, :dtriangle => -5, :pentagon => -14, | ||
:auto => 1, :ellipse => -1, :rect => -7, :diamond => -13, | ||
:utriangle => -3, :dtriangle => -5, :pentagon => -14, :hexagon => 3, | ||
:cross => 2, :xcross => 5, :star5 => 3 ) | ||
|
||
function gr_display(plt::Plot{GRPackage}) | ||
|
@@ -37,8 +37,13 @@ function gr_display(plt::Plot{GRPackage}) | |
x, y = p[:x], p[:y] | ||
xmin = min(minimum(x), xmin) | ||
xmax = max(maximum(x), xmax) | ||
ymin = min(minimum(y), ymin) | ||
ymax = max(maximum(y), ymax) | ||
# catch exception for OHLC vectors | ||
try | ||
ymin = min(minimum(y), ymin) | ||
ymax = max(maximum(y), ymax) | ||
catch MethodError | ||
ymin, ymax = 0, 1 | ||
end | ||
end | ||
|
||
scale = d[:scale] | ||
|
@@ -101,16 +106,27 @@ function gr_display(plt::Plot{GRPackage}) | |
GR.savestate() | ||
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]]) | ||
if haskey(d, :markersize) | ||
typeof(d[:markersize]) <: Number && GR.setmarkersize(d[:markersize] / 4.0) | ||
else | ||
println("TODO: multiple marker sizes") | ||
end | ||
if haskey(d, :markershape) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
jheinen
Author
Owner
|
||
typeof(d[:markershape]) == Symbol && GR.setmarkertype(gr_markertype[d[:markershape]]) | ||
else | ||
println("TODO: user-defined marker shapes") | ||
end | ||
GR.settextalign(GR.TEXT_HALIGN_LEFT, GR.TEXT_VALIGN_HALF) | ||
|
||
GR.uselinespec(" ") | ||
for p in plt.seriesargs | ||
GR.uselinespec("") | ||
if p[:linetype] == :path | ||
GR.polyline(p[:x], p[:y]) | ||
elseif p[:linetype] == :scatter | ||
GR.polymarker(p[:x], p[:y]) | ||
else | ||
println("TODO: add support for linetype $(p[:linetype])") | ||
end | ||
end | ||
|
||
|
@@ -131,6 +147,7 @@ function gr_display(plt::Plot{GRPackage}) | |
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]) | ||
GR.uselinespec(" ") | ||
for p in plt.seriesargs | ||
GR.uselinespec("") | ||
if p[:linetype] == :path | ||
|
@@ -155,6 +172,9 @@ end | |
|
||
function _add_series(::GRPackage, plt::Plot; kw...) | ||
d = Dict(kw) | ||
if d[:markershape] == :none | ||
d[:markershape] = :ellipse | ||
end | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
jheinen
Author
Owner
|
||
push!(plt.seriesargs, d) | ||
plt | ||
end | ||
|
@@ -188,23 +208,22 @@ end | |
|
||
# ---------------------------------------------------------------- | ||
|
||
# accessors for x/y data | ||
|
||
function Base.getindex(plt::Plot{GRPackage}, i::Int) | ||
series = plt.o.lines[i] | ||
series.x, series.y | ||
d = plt.seriesargs[i] | ||
d[:x], d[:y] | ||
end | ||
|
||
function Base.setindex!(plt::Plot{GRPackage}, xy::Tuple, i::Integer) | ||
series = plt.o.lines[i] | ||
series.x, series.y = xy | ||
d = plt.seriesargs[i] | ||
d[:x], d[:y] = xy | ||
plt | ||
end | ||
|
||
# ---------------------------------------------------------------- | ||
|
||
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 | ||
true | ||
end | ||
|
||
function _expand_limits(lims, plt::Plot{GRPackage}, isx::Bool) | ||
|
@@ -218,7 +237,8 @@ end | |
# ---------------------------------------------------------------- | ||
|
||
function Base.writemime(io::IO, ::MIME"image/png", plt::PlottingObject{GRPackage}) | ||
# TODO: write a png to io | ||
isijulia() && return | ||
println("TODO: write a png to io") | ||
end | ||
|
||
function Base.display(::PlotsDisplay, plt::Plot{GRPackage}) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -234,10 +234,11 @@ supportedArgs(::GRPackage) = [ | |
] | ||
supportedAxes(::GRPackage) = _allAxes | ||
supportedTypes(::GRPackage) = [:none, :line, :path, :steppre, :steppost, :sticks, | ||
:scatter, :heatmap, :hexbin, :hist, :density, :bar, | ||
:hline, :vline, :contour, :path3d, :scatter3d, :surface, :wireframe] | ||
:scatter, :heatmap, :hexbin, :hist, :density, :bar, | ||
:hline, :vline, :contour, :path3d, :scatter3d, :surface, | ||
:wireframe, :ohlc, :pie] | ||
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) | ||
This comment has been minimized.
Sorry, something went wrong.
tbreloff
|
||
supportedScales(::GRPackage) = [:identity, :log10] | ||
subplotSupported(::GRPackage) = true | ||
|
||
|
2 comments
on commit c5d2181
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also:
This branch is 1 commit ahead, 6 commits behind tbreloff:dev.
The commit history in Plots is going to get increasingly messy unless you periodically re-branch from the latest tbreloff:dev. Ideally you can get in the habit of rebasing on top of my dev branch to avoid the merging. See: http://docs.julialang.org/en/stable/manual/packages/#squashing-and-rebasing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry - I'll clean up tomorrow ...
I think
haskey(d, :markersize)
andhaskey(d, :markershape)
will always be true... did you mean to check the type here?