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,
|
||||
:o => :octagon,
|
||||
:oct => :octagon,
|
||||
:spike => :vline,
|
||||
)
|
||||
|
||||
const _allScales = [:identity, :log, :log2, :log10, :asinh, :sqrt]
|
||||
|
||||
@ -41,13 +41,13 @@ end
|
||||
# accessors for x/y data
|
||||
|
||||
function Base.getindex(plt::Plot{PlotlyPackage}, 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{PlotlyPackage}, 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
|
||||
|
||||
@ -68,7 +68,7 @@ end
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
|
||||
|
||||
# TODO:
|
||||
# _plotDefaults[:yrightlabel] = ""
|
||||
# _plotDefaults[:xlims] = :auto
|
||||
# _plotDefaults[:ylims] = :auto
|
||||
@ -95,6 +95,8 @@ function plotlyscale(scale::Symbol)
|
||||
end
|
||||
end
|
||||
|
||||
use_axis_field(ticks) = !(ticks in (nothing, :none))
|
||||
|
||||
function get_plot_json(plt::Plot{PlotlyPackage})
|
||||
d = plt.plotargs
|
||||
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 range
|
||||
|
||||
d_out[:xaxis] = Dict(
|
||||
:title => d[:xlabel],
|
||||
:titlefont => plotlyfont(d[:guidefont]),
|
||||
:type => plotlyscale(d[:xscale]),
|
||||
:tickfont => plotlyfont(d[:tickfont]),
|
||||
:tickcolor => fgcolor,
|
||||
:linecolor => fgcolor,
|
||||
:showgrid => d[:grid],
|
||||
:zeroline => false,
|
||||
)
|
||||
d_out[:xaxis] = if use_axis_field(d[:xticks])
|
||||
Dict(
|
||||
:title => d[:xlabel],
|
||||
:titlefont => plotlyfont(d[:guidefont]),
|
||||
:type => plotlyscale(d[:xscale]),
|
||||
:tickfont => plotlyfont(d[:tickfont]),
|
||||
:tickcolor => fgcolor,
|
||||
:linecolor => fgcolor,
|
||||
:showgrid => d[:grid],
|
||||
:zeroline => false,
|
||||
)
|
||||
else
|
||||
Dict(:showticklabels => false)
|
||||
end
|
||||
|
||||
d_out[:yaxis] = 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,
|
||||
)
|
||||
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]
|
||||
if d[:legend]
|
||||
@ -191,11 +210,13 @@ end
|
||||
plotly_colorscale(c) = plotly_colorscale(ColorGradient(:bluesreds))
|
||||
|
||||
const _plotly_markers = Dict(
|
||||
:rect => "square",
|
||||
:xcross => "x",
|
||||
:utriangle => "triangle-up",
|
||||
:dtriangle => "triangle-down",
|
||||
:star5 => "star-triangle-up",
|
||||
:rect => "square",
|
||||
:xcross => "x",
|
||||
:utriangle => "triangle-up",
|
||||
:dtriangle => "triangle-down",
|
||||
: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)
|
||||
|
||||
@ -463,12 +463,12 @@ supportedArgs(::PlotlyPackage) = [
|
||||
:x,
|
||||
:xlabel,
|
||||
# :xlims,
|
||||
# :xticks,
|
||||
:xticks,
|
||||
:y,
|
||||
:ylabel,
|
||||
# :ylims,
|
||||
# :yrightlabel,
|
||||
# :yticks,
|
||||
:yticks,
|
||||
:xscale,
|
||||
:yscale,
|
||||
# :xflip,
|
||||
@ -487,7 +487,7 @@ supportedTypes(::PlotlyPackage) = [:none, :line, :path, :scatter, :steppre, :ste
|
||||
:pie] #,, :sticks, :hexbin, :hline, :vline]
|
||||
supportedStyles(::PlotlyPackage) = [:auto, :solid, :dash, :dot, :dashdot]
|
||||
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]
|
||||
subplotSupported(::PlotlyPackage) = true
|
||||
stringsSupported(::PlotlyPackage) = true
|
||||
|
||||
@ -54,17 +54,19 @@ end
|
||||
|
||||
|
||||
const _shapes = @compat Dict(
|
||||
:ellipse => makeshape(20),
|
||||
:rect => makeshape(4, offset=-0.25),
|
||||
:diamond => makeshape(4),
|
||||
:utriangle => makeshape(3),
|
||||
:dtriangle => makeshape(3, offset=0.5),
|
||||
:pentagon => makeshape(5),
|
||||
:hexagon => makeshape(6),
|
||||
:heptagon => makeshape(7),
|
||||
:octagon => makeshape(8),
|
||||
:cross => makecross(offset=-0.25),
|
||||
:xcross => makecross(),
|
||||
:ellipse => makeshape(20),
|
||||
:rect => makeshape(4, offset=-0.25),
|
||||
:diamond => makeshape(4),
|
||||
:utriangle => makeshape(3),
|
||||
:dtriangle => makeshape(3, offset=0.5),
|
||||
:pentagon => makeshape(5),
|
||||
:hexagon => makeshape(6),
|
||||
:heptagon => makeshape(7),
|
||||
:octagon => makeshape(8),
|
||||
:cross => makecross(offset=-0.25),
|
||||
:xcross => makecross(),
|
||||
:vline => Shape([(0,1),(0,-1)]),
|
||||
:hline => Shape([(1,0),(-1,0)]),
|
||||
)
|
||||
|
||||
for n in [4,5,6,7,8]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user