diff --git a/src/Plots.jl b/src/Plots.jl index feca5ce9b..5dcd596d7 100644 --- a/src/Plots.jl +++ b/src/Plots.jl @@ -59,6 +59,7 @@ export path3d!, scatter3d, scatter3d!, + abline!, title!, xlabel!, diff --git a/src/backends/plotly.jl b/src/backends/plotly.jl index 00db4c62f..aa1141cbd 100644 --- a/src/backends/plotly.jl +++ b/src/backends/plotly.jl @@ -4,7 +4,7 @@ # --------------------------------------------------------------------------- function _create_plot(pkg::PlotlyPackage; kw...) - d = Dict(kw) + d = Dict{Symbol,Any}(kw) # TODO: create the window/canvas/context that is the plot within the backend (call it `o`) # TODO: initialize the plot... title, xlabel, bgcolor, etc Plot(nothing, pkg, 0, d, Dict[]) @@ -12,7 +12,7 @@ end function _add_series(::PlotlyPackage, plt::Plot; kw...) - d = Dict(kw) + d = Dict{Symbol,Any}(kw) # TODO: add one series to the underlying package push!(plt.seriesargs, d) plt @@ -83,7 +83,7 @@ end # _plotDefaults[:yflip] = false function plotlyfont(font::Font, color = font.color) - Dict( + Dict{Symbol,Any}( :family => font.family, :size => round(Int, font.pointsize*1.4), :color => webcolor(color), @@ -91,7 +91,7 @@ function plotlyfont(font::Font, color = font.color) end function get_annotation_dict(x, y, val::Union{AbstractString,Symbol}) - Dict( + Dict{Symbol,Any}( :text => val, :xref => "x", :x => x, @@ -102,7 +102,7 @@ function get_annotation_dict(x, y, val::Union{AbstractString,Symbol}) end function get_annotation_dict(x, y, ptxt::PlotText) - merge(get_annotation_dict(x, y, ptxt.str), Dict( + merge(get_annotation_dict(x, y, ptxt.str), Dict{Symbol,Any}( :font => plotlyfont(ptxt.font), :xanchor => ptxt.font.halign == :hcenter ? :center : ptxt.font.halign, :yanchor => ptxt.font.valign == :vcenter ? :middle : ptxt.font.valign, @@ -127,7 +127,7 @@ scalesym(isx::Bool) = symbol((isx ? "x" : "y") * "scale") labelsym(isx::Bool) = symbol((isx ? "x" : "y") * "label") function plotlyaxis(d::Dict, isx::Bool) - ax = Dict( + ax = Dict{Symbol,Any}( :title => d[labelsym(isx)], :showgrid => d[:grid], :zeroline => false, @@ -179,7 +179,7 @@ end # function get_plot_json(plt::Plot{PlotlyPackage}) # d = plt.plotargs function plotly_layout(d::Dict) - d_out = Dict() + d_out = Dict{Symbol,Any}() bgcolor = webcolor(d[:background_color]) fgcolor = webcolor(d[:foreground_color]) @@ -187,10 +187,10 @@ function plotly_layout(d::Dict) # set the fields for the plot d_out[:title] = d[:title] d_out[:titlefont] = plotlyfont(d[:guidefont], fgcolor) - d_out[:margin] = Dict(:l=>35, :b=>30, :r=>8, :t=>20) + d_out[:margin] = Dict{Symbol,Any}(:l=>35, :b=>30, :r=>8, :t=>20) d_out[:plot_bgcolor] = bgcolor d_out[:paper_bgcolor] = bgcolor - + # TODO: x/y axis tick values/labels d_out[:xaxis] = plotlyaxis(d, true) d_out[:yaxis] = plotlyaxis(d, false) @@ -198,7 +198,7 @@ function plotly_layout(d::Dict) # legend d_out[:showlegend] = d[:legend] if d[:legend] - d_out[:legend] = Dict( + d_out[:legend] = Dict{Symbol,Any}( :bgcolor => bgcolor, :bordercolor => fgcolor, :font => plotlyfont(d[:legendfont]), @@ -224,7 +224,7 @@ function plotly_colorscale(grad::ColorGradient) end plotly_colorscale(c) = plotly_colorscale(ColorGradient(:bluesreds)) -const _plotly_markers = Dict( +const _plotly_markers = Dict{Symbol,Any}( :rect => "square", :xcross => "x", :utriangle => "triangle-up", @@ -236,7 +236,7 @@ const _plotly_markers = Dict( # get a dictionary representing the series params (d is the Plots-dict, d_out is the Plotly-dict) function plotly_series(d::Dict; plot_index = nothing) - d_out = Dict() + d_out = Dict{Symbol,Any}() x, y = collect(d[:x]), collect(d[:y]) d_out[:name] = d[:label] @@ -293,7 +293,7 @@ function plotly_series(d::Dict; plot_index = nothing) # d_out[:showscale] = d[:legend] if lt == :contour d_out[:ncontours] = d[:levels] - d_out[:contours] = Dict(:coloring => d[:fillrange] != nothing ? "fill" : "lines") + d_out[:contours] = Dict{Symbol,Any}(:coloring => d[:fillrange] != nothing ? "fill" : "lines") end d_out[:colorscale] = plotly_colorscale(d[lt == :contour ? :linecolor : :fillcolor]) @@ -315,17 +315,17 @@ function plotly_series(d::Dict; plot_index = nothing) else warn("Plotly: linetype $lt isn't supported.") - return Dict() + return Dict{Symbol,Any}() end # add "marker" if hasmarker - d_out[:marker] = Dict( + d_out[:marker] = Dict{Symbol,Any}( :symbol => get(_plotly_markers, d[:markershape], string(d[:markershape])), :opacity => d[:markeralpha], :size => 2 * d[:markersize], :color => webcolor(d[:markercolor], d[:markeralpha]), - :line => Dict( + :line => Dict{Symbol,Any}( :color => webcolor(d[:markerstrokecolor], d[:markerstrokealpha]), :width => d[:markerstrokewidth], ), @@ -338,7 +338,7 @@ function plotly_series(d::Dict; plot_index = nothing) # add "line" if hasline - d_out[:line] = Dict( + d_out[:line] = Dict{Symbol,Any}( :color => webcolor(d[:linecolor], d[:linealpha]), :width => d[:linewidth], :shape => if lt == :steppre @@ -405,10 +405,10 @@ function html_body(subplt::Subplot{PlotlyPackage}) html = ["