added vline/hline marker shapes; plotly set/get, ticks
This commit is contained in:
parent
2a60a929f1
commit
e18c4a370a
@ -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]
|
||||||
|
|||||||
@ -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,26 +118,43 @@ 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])
|
||||||
:title => d[:xlabel],
|
Dict(
|
||||||
:titlefont => plotlyfont(d[:guidefont]),
|
:title => d[:xlabel],
|
||||||
:type => plotlyscale(d[:xscale]),
|
:titlefont => plotlyfont(d[:guidefont]),
|
||||||
:tickfont => plotlyfont(d[:tickfont]),
|
:type => plotlyscale(d[:xscale]),
|
||||||
:tickcolor => fgcolor,
|
:tickfont => plotlyfont(d[:tickfont]),
|
||||||
:linecolor => fgcolor,
|
:tickcolor => fgcolor,
|
||||||
:showgrid => d[:grid],
|
:linecolor => fgcolor,
|
||||||
:zeroline => false,
|
:showgrid => d[:grid],
|
||||||
)
|
:zeroline => false,
|
||||||
|
)
|
||||||
|
else
|
||||||
|
Dict(:showticklabels => false)
|
||||||
|
end
|
||||||
|
|
||||||
d_out[:yaxis] = Dict(
|
d_out[:yaxis] = Dict(
|
||||||
:title => d[:ylabel],
|
:title => d[:ylabel],
|
||||||
:titlefont => plotlyfont(d[:guidefont]),
|
|
||||||
:type => plotlyscale(d[:yscale]),
|
|
||||||
:tickfont => plotlyfont(d[:tickfont]),
|
|
||||||
:tickcolor => fgcolor,
|
|
||||||
:linecolor => fgcolor,
|
|
||||||
:showgrid => d[:grid],
|
:showgrid => d[:grid],
|
||||||
:zeroline => false,
|
:zeroline => false,
|
||||||
)
|
)
|
||||||
|
merge!(d_out[:yaxis], if use_axis_field(d[:yticks])
|
||||||
|
Dict(
|
||||||
|
# :title => d[:ylabel],
|
||||||
|
:titlefont => plotlyfont(d[:guidefont]),
|
||||||
|
:type => plotlyscale(d[:yscale]),
|
||||||
|
:tickfont => plotlyfont(d[:tickfont]),
|
||||||
|
:tickcolor => fgcolor,
|
||||||
|
:linecolor => fgcolor,
|
||||||
|
# :showgrid => d[:grid],
|
||||||
|
# :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]
|
||||||
@ -191,11 +210,13 @@ end
|
|||||||
plotly_colorscale(c) = plotly_colorscale(ColorGradient(:bluesreds))
|
plotly_colorscale(c) = plotly_colorscale(ColorGradient(:bluesreds))
|
||||||
|
|
||||||
const _plotly_markers = Dict(
|
const _plotly_markers = Dict(
|
||||||
:rect => "square",
|
:rect => "square",
|
||||||
:xcross => "x",
|
:xcross => "x",
|
||||||
: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)
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
@ -54,17 +54,19 @@ end
|
|||||||
|
|
||||||
|
|
||||||
const _shapes = @compat Dict(
|
const _shapes = @compat Dict(
|
||||||
:ellipse => makeshape(20),
|
:ellipse => 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),
|
||||||
:dtriangle => makeshape(3, offset=0.5),
|
:dtriangle => makeshape(3, offset=0.5),
|
||||||
:pentagon => makeshape(5),
|
:pentagon => makeshape(5),
|
||||||
:hexagon => makeshape(6),
|
:hexagon => makeshape(6),
|
||||||
:heptagon => makeshape(7),
|
:heptagon => makeshape(7),
|
||||||
: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]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user