rename ellipse to circle; cleanup glvisualize

This commit is contained in:
Thomas Breloff 2016-06-13 15:59:51 -04:00
parent c44132d29d
commit 1ba0d198a7
14 changed files with 76 additions and 123 deletions

View File

@ -91,8 +91,9 @@ const _allMarkers = vcat(:none, :auto, sort(collect(keys(_shapes))))
:n => :none, :n => :none,
:no => :none, :no => :none,
:a => :auto, :a => :auto,
:circle => :ellipse, :ellipse => :circle,
:c => :ellipse, :c => :circle,
:circ => :circle,
:square => :rect, :square => :rect,
:sq => :rect, :sq => :rect,
:r => :rect, :r => :rect,
@ -628,7 +629,7 @@ function preprocessArgs!(d::KW)
if haskey(d, :markershape) if haskey(d, :markershape)
d[:markershape] = _replace_markershape(d[:markershape]) d[:markershape] = _replace_markershape(d[:markershape])
elseif anymarker elseif anymarker
d[:markershape_to_add] = :ellipse # add it after _apply_recipe d[:markershape_to_add] = :circle # add it after _apply_recipe
end end
# handle fill # handle fill

View File

@ -61,7 +61,7 @@ supported_args(::BokehBackend) = merge_with_base_supported([
]) ])
supported_types(::BokehBackend) = [:path, :scatter] supported_types(::BokehBackend) = [:path, :scatter]
supported_styles(::BokehBackend) = [:auto, :solid, :dash, :dot, :dashdot, :dashdotdot] supported_styles(::BokehBackend) = [:auto, :solid, :dash, :dot, :dashdot, :dashdotdot]
supported_markers(::BokehBackend) = [:none, :auto, :ellipse, :rect, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star5] supported_markers(::BokehBackend) = [:none, :auto, :circle, :rect, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star5]
supported_scales(::BokehBackend) = [:identity, :ln] supported_scales(::BokehBackend) = [:identity, :ln]
is_subplot_supported(::BokehBackend) = false is_subplot_supported(::BokehBackend) = false
@ -80,7 +80,7 @@ end
const _glyphtypes = KW( const _glyphtypes = KW(
:ellipse => :Circle, :circle => :Circle,
:rect => :Square, :rect => :Square,
:diamond => :Diamond, :diamond => :Diamond,
:utriangle => :Triangle, :utriangle => :Triangle,
@ -99,7 +99,7 @@ function bokeh_glyph_type(d::KW)
st = d[:seriestype] st = d[:seriestype]
mt = d[:markershape] mt = d[:markershape]
if st == :scatter && mt == :none if st == :scatter && mt == :none
mt = :ellipse mt = :circle
end end
# if we have a marker, use that # if we have a marker, use that

View File

@ -301,7 +301,7 @@ function addGadflySeries!(plt::Plot, d::KW)
if st in (:histogram2d, :hexbin) && (isa(d[:fillcolor], ColorGradient) || isa(d[:fillcolor], ColorFunction)) if st in (:histogram2d, :hexbin) && (isa(d[:fillcolor], ColorGradient) || isa(d[:fillcolor], ColorFunction))
push!(gplt.scales, Gadfly.Scale.ContinuousColorScale(p -> RGB(getColorZ(d[:fillcolor], p)))) push!(gplt.scales, Gadfly.Scale.ContinuousColorScale(p -> RGB(getColorZ(d[:fillcolor], p))))
elseif st == :scatter && d[:markershape] == :none elseif st == :scatter && d[:markershape] == :none
d[:markershape] = :ellipse d[:markershape] = :circle
end end
# markers # markers

View File

@ -4,64 +4,34 @@
supported_args(::GLVisualizeBackend) = merge_with_base_supported([ supported_args(::GLVisualizeBackend) = merge_with_base_supported([
# :annotations, # :annotations,
# :axis, # :background_color_legend, :background_color_inside, :background_color_outside,
# :background_color, # :foreground_color_grid, :foreground_color_legend, :foreground_color_title,
# :color_palette, # :foreground_color_axis, :foreground_color_border, :foreground_color_guide, :foreground_color_text,
# :fillrange,
# :fillcolor,
# :fillalpha,
# :foreground_color,
# :group,
# :label, # :label,
# :layout, # :linecolor, :linestyle, :linewidth, :linealpha,
# :legend, # :markershape, :markercolor, :markersize, :markeralpha,
# :linecolor, # :markerstrokewidth, :markerstrokecolor, :markerstrokealpha,
# :linestyle, # :fillrange, :fillcolor, :fillalpha,
# :seriestype # :bins, :bar_width, :bar_edges, :bar_position,
# :seriescolor, :seriesalpha, # :title, :title_location, :titlefont,
# :linewidth,
# :linealpha,
# :markershape,
# :markercolor,
# :markersize,
# :markeralpha,
# :markerstrokewidth,
# :markerstrokecolor,
# :markerstrokestyle,
# :n,
# :bins,
# :nc,
# :nr,
# :pos,
# :smooth,
# :show,
# :size,
# :title,
# :window_title, # :window_title,
# :x, # :guide, :lims, :ticks, :scale, :flip, :rotation,
# :xguide, # :tickfont, :guidefont, :legendfont,
# :xlims, # :grid, :legend, :colorbar,
# :xticks, # :marker_z, :levels,
# :y, # :ribbon, :quiver, :arrow,
# :yguide, # :orientation,
# :ylims, # :overwrite_figure,
# :yrightlabel, # :polar,
# :yticks, # :normalize, :weights,
# :xscale, # :contours, :aspect_ratio,
# :yscale, # :match_dimensions,
# :xflip, # :clims,
# :yflip, # :inset_subplots,
# :z,
# :tickfont,
# :guidefont,
# :legendfont,
# :grid,
# :surface
# :levels,
]) ])
supported_types(::GLVisualizeBackend) = [:surface] supported_types(::GLVisualizeBackend) = [:surface]
supported_styles(::GLVisualizeBackend) = [:auto, :solid] supported_styles(::GLVisualizeBackend) = [:auto, :solid]
supported_markers(::GLVisualizeBackend) = [:none, :auto, :ellipse] supported_markers(::GLVisualizeBackend) = [:none, :auto, :circle]
supported_scales(::GLVisualizeBackend) = [:identity] supported_scales(::GLVisualizeBackend) = [:identity]
is_subplot_supported(::GLVisualizeBackend) = false is_subplot_supported(::GLVisualizeBackend) = false
@ -81,55 +51,37 @@ immutable GLScreenWrapper
window window
end end
# function _create_plot(pkg::GLVisualizeBackend, d::KW) function gl_display(plt::Plot{GLVisualizeBackend})
function _create_backend_figure(plt::Plot{GLVisualizeBackend}) # init a window
# TODO: create the window/canvas/context that is the plot within the backend
# TODO: initialize the plot... title, xlabel, bgcolor, etc
# TODO: this should be moved to the display method?
w=GLVisualize.glscreen() w=GLVisualize.glscreen()
@async GLVisualize.renderloop(w) @async GLVisualize.renderloop(w)
GLScreenWrapper(w) GLScreenWrapper(w)
# Plot(GLScreenWrapper(w), pkg, 0, d, KW[])
end
for sp in plt.subplots
# TODO: setup subplot
# ---------------------------------------------------------------- for series in series_list(sp)
# TODO: setup series
d = series.d
st = d[:seriestype]
function _series_added(plt::Plot{GLVisualizeBackend}, series::Series) if st == :surface
# TODO: add one series to the underlying package
# TODO: this should be moved to the display method?
x, y, z = map(Float32, series.d[:x]), map(Float32, series.d[:y]), map(Float32, series.d[:z].surf) x, y, z = map(Float32, series.d[:x]), map(Float32, series.d[:y]), map(Float32, series.d[:z].surf)
GLVisualize.view(GLVisualize.visualize((x*ones(y)', ones(x)*y', z), :surface), plt.o.window) GLVisualize.view(GLVisualize.visualize((x*ones(y)', ones(x)*y', z), :surface), plt.o.window)
# plt else
error("Series type $st not supported by GLVisualize")
end
end end
# When series data is added/changed, this callback can do dynamic updates to the backend object.
# note: if the backend rebuilds the plot from scratch on display, then you might not do anything here.
function _series_updated(plt::Plot{GLVisualizeBackend}, series::Series)
# TODO
end end
# ----------------------------------------------------------------
# Override this to update plot items (title, xlabel, etc), and add annotations (d[:annotations])
function _update_plot_object(plt::Plot{GLVisualizeBackend})
# TODO
end end
# ---------------------------------------------------------------- # ----------------------------------------------------------------
function _writemime(io::IO, ::MIME"image/png", plt::AbstractPlot{GLVisualizeBackend}) # function _writemime(io::IO, ::MIME"image/png", plt::AbstractPlot{GLVisualizeBackend})
# TODO: write a png to io # # TODO: write a png to io
end # end
function _display(plt::Plot{GLVisualizeBackend}) function _display(plt::Plot{GLVisualizeBackend})
# TODO: display/show the plot gl_display(plt)
# NOTE: I think maybe this should be empty? We can start with the assumption that creating
# and adding to a plot will automatically open a window and draw to it, then the display
# wouldn't actually need to do anything
end end

View File

@ -63,7 +63,7 @@ const gr_linetype = KW(
const gr_markertype = KW( const gr_markertype = KW(
:auto => 1, :auto => 1,
:none => -1, :none => -1,
:ellipse => -1, :circle => -1,
:rect => -7, :rect => -7,
:diamond => -13, :diamond => -13,
:utriangle => -3, :utriangle => -3,

View File

@ -34,7 +34,7 @@ supported_args(::PGFPlotsBackend) = merge_with_base_supported([
]) ])
supported_types(::PGFPlotsBackend) = [:path, :path3d, :scatter, :steppre, :stepmid, :steppost, :histogram2d, :ysticks, :xsticks, :contour] supported_types(::PGFPlotsBackend) = [:path, :path3d, :scatter, :steppre, :stepmid, :steppost, :histogram2d, :ysticks, :xsticks, :contour]
supported_styles(::PGFPlotsBackend) = [:auto, :solid, :dash, :dot, :dashdot, :dashdotdot] supported_styles(::PGFPlotsBackend) = [:auto, :solid, :dash, :dot, :dashdot, :dashdotdot]
supported_markers(::PGFPlotsBackend) = [:none, :auto, :ellipse, :rect, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star5, :pentagon] #vcat(_allMarkers, Shape) supported_markers(::PGFPlotsBackend) = [:none, :auto, :circle, :rect, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star5, :pentagon] #vcat(_allMarkers, Shape)
supported_scales(::PGFPlotsBackend) = [:identity, :ln, :log2, :log10] supported_scales(::PGFPlotsBackend) = [:identity, :ln, :log2, :log10]
is_subplot_supported(::PGFPlotsBackend) = false is_subplot_supported(::PGFPlotsBackend) = false
@ -66,7 +66,7 @@ const _pgfplots_markers = KW(
:xcross => "x", :xcross => "x",
:utriangle => "triangle*", :utriangle => "triangle*",
:dtriangle => "triangle*", :dtriangle => "triangle*",
:ellipse => "*", :circle => "*",
:rect => "square*", :rect => "square*",
:star5 => "star", :star5 => "star",
:star6 => "asterisk", :star6 => "asterisk",

View File

@ -37,7 +37,7 @@ supported_types(::PlotlyBackend) = [
] ]
supported_styles(::PlotlyBackend) = [:auto, :solid, :dash, :dot, :dashdot] supported_styles(::PlotlyBackend) = [:auto, :solid, :dash, :dot, :dashdot]
supported_markers(::PlotlyBackend) = [ supported_markers(::PlotlyBackend) = [
:none, :auto, :ellipse, :rect, :diamond, :utriangle, :dtriangle, :none, :auto, :circle, :rect, :diamond, :utriangle, :dtriangle,
:cross, :xcross, :pentagon, :hexagon, :octagon, :vline, :hline :cross, :xcross, :pentagon, :hexagon, :octagon, :vline, :hline
] ]
supported_scales(::PlotlyBackend) = [:identity, :log10] supported_scales(::PlotlyBackend) = [:identity, :log10]

View File

@ -149,7 +149,7 @@ end
# get the marker shape # get the marker shape
function py_marker(marker::Symbol) function py_marker(marker::Symbol)
marker == :none && return " " marker == :none && return " "
marker == :ellipse && return "o" marker == :circle && return "o"
marker == :rect && return "s" marker == :rect && return "s"
marker == :diamond && return "D" marker == :diamond && return "D"
marker == :utriangle && return "^" marker == :utriangle && return "^"

View File

@ -22,7 +22,7 @@ supported_args(::QwtBackend) = merge_with_base_supported([
:guide, :lims, :ticks, :scale, :guide, :lims, :ticks, :scale,
]) ])
supported_types(::QwtBackend) = [:path, :scatter, :hexbin, :bar] supported_types(::QwtBackend) = [:path, :scatter, :hexbin, :bar]
supported_markers(::QwtBackend) = [:none, :auto, :rect, :ellipse, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star5, :star8, :hexagon] supported_markers(::QwtBackend) = [:none, :auto, :rect, :circle, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star5, :star8, :hexagon]
supported_scales(::QwtBackend) = [:identity, :log10] supported_scales(::QwtBackend) = [:identity, :log10]
is_subplot_supported(::QwtBackend) = true is_subplot_supported(::QwtBackend) = true
@ -72,13 +72,13 @@ function adjustQwtKeywords(plt::Plot{QwtBackend}, iscreating::Bool; kw...)
if st == :scatter if st == :scatter
d[:seriestype] = :none d[:seriestype] = :none
if d[:markershape] == :none if d[:markershape] == :none
d[:markershape] = :ellipse d[:markershape] = :circle
end end
elseif st in (:hline, :vline) elseif st in (:hline, :vline)
addLineMarker(plt, d) addLineMarker(plt, d)
d[:seriestype] = :none d[:seriestype] = :none
d[:markershape] = :ellipse d[:markershape] = :circle
d[:markersize] = 1 d[:markersize] = 1
if st == :vline if st == :vline
d[:x], d[:y] = d[:y], d[:x] d[:x], d[:y] = d[:y], d[:x]

View File

@ -17,7 +17,7 @@ supported_types(::UnicodePlotsBackend) = [
:histogram2d :histogram2d
] ]
supported_styles(::UnicodePlotsBackend) = [:auto, :solid] supported_styles(::UnicodePlotsBackend) = [:auto, :solid]
supported_markers(::UnicodePlotsBackend) = [:none, :auto, :ellipse] supported_markers(::UnicodePlotsBackend) = [:none, :auto, :circle]
supported_scales(::UnicodePlotsBackend) = [:identity] supported_scales(::UnicodePlotsBackend) = [:identity]
is_subplot_supported(::UnicodePlotsBackend) = true is_subplot_supported(::UnicodePlotsBackend) = true

View File

@ -23,7 +23,7 @@ supported_args(::WinstonBackend) = merge_with_base_supported([
]) ])
supported_types(::WinstonBackend) = [:path, :scatter, :bar] supported_types(::WinstonBackend) = [:path, :scatter, :bar]
supported_styles(::WinstonBackend) = [:auto, :solid, :dash, :dot, :dashdot] supported_styles(::WinstonBackend) = [:auto, :solid, :dash, :dot, :dashdot]
supported_markers(::WinstonBackend) = [:none, :auto, :rect, :ellipse, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star5] supported_markers(::WinstonBackend) = [:none, :auto, :rect, :circle, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star5]
supported_scales(::WinstonBackend) = [:identity, :log10] supported_scales(::WinstonBackend) = [:identity, :log10]
is_subplot_supported(::WinstonBackend) = false is_subplot_supported(::WinstonBackend) = false
@ -52,7 +52,7 @@ end
@compat const winston_marker = KW(:none=>".", @compat const winston_marker = KW(:none=>".",
:rect => "square", :rect => "square",
:ellipse=>"circle", :circle=>"circle",
:diamond=>"diamond", :diamond=>"diamond",
:utriangle=>"triangle", :utriangle=>"triangle",
:dtriangle=>"down-triangle", :dtriangle=>"down-triangle",
@ -135,7 +135,7 @@ function _series_added(plt::Plot{WinstonBackend}, series::Series)
elseif d[:seriestype] == :scatter elseif d[:seriestype] == :scatter
if d[:markershape] == :none if d[:markershape] == :none
d[:markershape] = :ellipse d[:markershape] = :circle
end end
# elseif d[:seriestype] == :step # elseif d[:seriestype] == :step

View File

@ -101,7 +101,7 @@ function makearrowhead(angle; h = 2.0, w = 0.4)
end end
const _shapes = KW( const _shapes = KW(
:ellipse => makeshape(20), :circle => makeshape(20),
:rect => makeshape(4, offset=-0.25), :rect => makeshape(4, offset=-0.25),
:diamond => makeshape(4), :diamond => makeshape(4),
:utriangle => makeshape(3), :utriangle => makeshape(3),

View File

@ -501,7 +501,7 @@ end
@recipe function f(::Type{Val{:scatter3d}}, x, y, z) @recipe function f(::Type{Val{:scatter3d}}, x, y, z)
seriestype := :path3d seriestype := :path3d
if d[:markershape] == :none if d[:markershape] == :none
markershape := :ellipse markershape := :circle
end end
linewidth := 0 linewidth := 0
linealpha := 0 linealpha := 0
@ -606,7 +606,7 @@ notch_width(q2, q4, N) = 1.58 * (q4-q2)/sqrt(N)
# Outliers # Outliers
@series begin @series begin
seriestype := :scatter seriestype := :scatter
markershape := :ellipse markershape := :circle
x := outliers_x x := outliers_x
y := outliers_y y := outliers_y
label := "" label := ""

View File

@ -56,7 +56,7 @@ function _add_defaults!(d::KW, plt::Plot, sp::Subplot, commandIndex::Int)
if d[:seriestype] in (:scatter, :scatter3d) if d[:seriestype] in (:scatter, :scatter3d)
d[:linewidth] = 0 d[:linewidth] = 0
if d[:markershape] == :none if d[:markershape] == :none
d[:markershape] = :ellipse d[:markershape] = :circle
end end
end end