added vline/hline marker shapes; plotly set/get, ticks

This commit is contained in:
Thomas Breloff 2015-12-16 11:14:06 -05:00
parent 2a60a929f1
commit e18c4a370a
4 changed files with 63 additions and 39 deletions

View File

@ -90,6 +90,7 @@ const _allMarkers = vcat(:none, :auto, sort(collect(keys(_shapes))))
:hep => :heptagon, :hep => :heptagon,
:o => :octagon, :o => :octagon,
:oct => :octagon, :oct => :octagon,
:spike => :vline,
) )
const _allScales = [:identity, :log, :log2, :log10, :asinh, :sqrt] const _allScales = [:identity, :log, :log2, :log10, :asinh, :sqrt]

View File

@ -41,13 +41,13 @@ end
# accessors for x/y data # accessors for x/y data
function Base.getindex(plt::Plot{PlotlyPackage}, i::Int) function Base.getindex(plt::Plot{PlotlyPackage}, 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{PlotlyPackage}, xy::Tuple, i::Integer) function Base.setindex!(plt::Plot{PlotlyPackage}, 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
@ -68,7 +68,7 @@ end
# ---------------------------------------------------------------- # ----------------------------------------------------------------
# TODO:
# _plotDefaults[:yrightlabel] = "" # _plotDefaults[:yrightlabel] = ""
# _plotDefaults[:xlims] = :auto # _plotDefaults[:xlims] = :auto
# _plotDefaults[:ylims] = :auto # _plotDefaults[:ylims] = :auto
@ -95,6 +95,8 @@ function plotlyscale(scale::Symbol)
end end
end end
use_axis_field(ticks) = !(ticks in (nothing, :none))
function get_plot_json(plt::Plot{PlotlyPackage}) function get_plot_json(plt::Plot{PlotlyPackage})
d = plt.plotargs d = plt.plotargs
d_out = Dict() d_out = Dict()
@ -116,7 +118,8 @@ function get_plot_json(plt::Plot{PlotlyPackage})
# TODO: x/y axis tick values/labels # TODO: x/y axis tick values/labels
# TODO: x/y axis range # TODO: x/y axis range
d_out[:xaxis] = Dict( d_out[:xaxis] = if use_axis_field(d[:xticks])
Dict(
:title => d[:xlabel], :title => d[:xlabel],
:titlefont => plotlyfont(d[:guidefont]), :titlefont => plotlyfont(d[:guidefont]),
:type => plotlyscale(d[:xscale]), :type => plotlyscale(d[:xscale]),
@ -126,16 +129,32 @@ function get_plot_json(plt::Plot{PlotlyPackage})
:showgrid => d[:grid], :showgrid => d[:grid],
:zeroline => false, :zeroline => false,
) )
else
Dict(:showticklabels => false)
end
d_out[:yaxis] = Dict( d_out[:yaxis] = Dict(
:title => d[:ylabel], :title => d[:ylabel],
:showgrid => d[:grid],
:zeroline => false,
)
merge!(d_out[:yaxis], if use_axis_field(d[:yticks])
Dict(
# :title => d[:ylabel],
:titlefont => plotlyfont(d[:guidefont]), :titlefont => plotlyfont(d[:guidefont]),
:type => plotlyscale(d[:yscale]), :type => plotlyscale(d[:yscale]),
:tickfont => plotlyfont(d[:tickfont]), :tickfont => plotlyfont(d[:tickfont]),
:tickcolor => fgcolor, :tickcolor => fgcolor,
:linecolor => fgcolor, :linecolor => fgcolor,
:showgrid => d[:grid], # :showgrid => d[:grid],
:zeroline => false, # :zeroline => false,
) )
else
Dict(
:showticklabels => false,
:showgrid => false,
)
end)
d_out[:showlegend] = d[:legend] d_out[:showlegend] = d[:legend]
if d[:legend] if d[:legend]
@ -196,6 +215,8 @@ const _plotly_markers = Dict(
:utriangle => "triangle-up", :utriangle => "triangle-up",
:dtriangle => "triangle-down", :dtriangle => "triangle-down",
:star5 => "star-triangle-up", :star5 => "star-triangle-up",
:vline => "line-ns",
:hline => "line-ew",
) )
# get a dictionary representing the series params (d is the Plots-dict, d_out is the Plotly-dict) # get a dictionary representing the series params (d is the Plots-dict, d_out is the Plotly-dict)

View File

@ -463,12 +463,12 @@ supportedArgs(::PlotlyPackage) = [
:x, :x,
:xlabel, :xlabel,
# :xlims, # :xlims,
# :xticks, :xticks,
:y, :y,
:ylabel, :ylabel,
# :ylims, # :ylims,
# :yrightlabel, # :yrightlabel,
# :yticks, :yticks,
:xscale, :xscale,
:yscale, :yscale,
# :xflip, # :xflip,
@ -487,7 +487,7 @@ supportedTypes(::PlotlyPackage) = [:none, :line, :path, :scatter, :steppre, :ste
:pie] #,, :sticks, :hexbin, :hline, :vline] :pie] #,, :sticks, :hexbin, :hline, :vline]
supportedStyles(::PlotlyPackage) = [:auto, :solid, :dash, :dot, :dashdot] supportedStyles(::PlotlyPackage) = [:auto, :solid, :dash, :dot, :dashdot]
supportedMarkers(::PlotlyPackage) = [:none, :auto, :ellipse, :rect, :diamond, :utriangle, :dtriangle, :cross, :xcross, supportedMarkers(::PlotlyPackage) = [:none, :auto, :ellipse, :rect, :diamond, :utriangle, :dtriangle, :cross, :xcross,
:pentagon, :hexagon, :octagon] #vcat(_allMarkers, Shape) :pentagon, :hexagon, :octagon, :vline, :hline] #vcat(_allMarkers, Shape)
supportedScales(::PlotlyPackage) = [:identity, :log] #, :log, :log2, :log10, :asinh, :sqrt] supportedScales(::PlotlyPackage) = [:identity, :log] #, :log, :log2, :log10, :asinh, :sqrt]
subplotSupported(::PlotlyPackage) = true subplotSupported(::PlotlyPackage) = true
stringsSupported(::PlotlyPackage) = true stringsSupported(::PlotlyPackage) = true

View File

@ -65,6 +65,8 @@ const _shapes = @compat Dict(
:octagon => makeshape(8), :octagon => makeshape(8),
:cross => makecross(offset=-0.25), :cross => makecross(offset=-0.25),
:xcross => makecross(), :xcross => makecross(),
:vline => Shape([(0,1),(0,-1)]),
:hline => Shape([(1,0),(-1,0)]),
) )
for n in [4,5,6,7,8] for n in [4,5,6,7,8]