Merge branch 'master' into ds-heatmap-logscale
This commit is contained in:
commit
9b2da0d645
2
REQUIRE
2
REQUIRE
@ -4,7 +4,7 @@ RecipesBase 0.2.0
|
|||||||
PlotUtils 0.4.1
|
PlotUtils 0.4.1
|
||||||
PlotThemes 0.1.3
|
PlotThemes 0.1.3
|
||||||
Reexport
|
Reexport
|
||||||
FixedSizeArrays
|
StaticArrays 0.5
|
||||||
FixedPointNumbers 0.3
|
FixedPointNumbers 0.3
|
||||||
Measures
|
Measures
|
||||||
Showoff
|
Showoff
|
||||||
|
|||||||
@ -3,7 +3,7 @@ __precompile__(true)
|
|||||||
module Plots
|
module Plots
|
||||||
|
|
||||||
using Reexport
|
using Reexport
|
||||||
using FixedSizeArrays
|
using StaticArrays.FixedSizeArrays
|
||||||
@reexport using RecipesBase
|
@reexport using RecipesBase
|
||||||
import RecipesBase: plot, animate
|
import RecipesBase: plot, animate
|
||||||
using Base.Meta
|
using Base.Meta
|
||||||
|
|||||||
@ -544,6 +544,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
viewport_plotarea[:] = gr_viewport_from_bbox(sp, plotarea(sp), w, h, viewport_canvas)
|
viewport_plotarea[:] = gr_viewport_from_bbox(sp, plotarea(sp), w, h, viewport_canvas)
|
||||||
# get data limits
|
# get data limits
|
||||||
data_lims = gr_xy_axislims(sp)
|
data_lims = gr_xy_axislims(sp)
|
||||||
|
xy_lims = data_lims
|
||||||
|
|
||||||
ratio = sp[:aspect_ratio]
|
ratio = sp[:aspect_ratio]
|
||||||
if ratio != :none
|
if ratio != :none
|
||||||
@ -586,6 +587,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
if st == :heatmap
|
if st == :heatmap
|
||||||
outside_ticks = true
|
outside_ticks = true
|
||||||
x, y = heatmap_edges(series[:x], sp[:xaxis][:scale]), heatmap_edges(series[:y], sp[:yaxis][:scale])
|
x, y = heatmap_edges(series[:x], sp[:xaxis][:scale]), heatmap_edges(series[:y], sp[:yaxis][:scale])
|
||||||
|
xy_lims = x[1], x[end], y[1], y[end]
|
||||||
expand_extrema!(sp[:xaxis], x)
|
expand_extrema!(sp[:xaxis], x)
|
||||||
expand_extrema!(sp[:yaxis], y)
|
expand_extrema!(sp[:yaxis], y)
|
||||||
data_lims = gr_xy_axislims(sp)
|
data_lims = gr_xy_axislims(sp)
|
||||||
@ -873,6 +875,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
cmap && gr_colorbar(sp)
|
cmap && gr_colorbar(sp)
|
||||||
|
|
||||||
elseif st == :heatmap
|
elseif st == :heatmap
|
||||||
|
xmin, xmax, ymin, ymax = xy_lims
|
||||||
zmin, zmax = gr_lims(zaxis, true)
|
zmin, zmax = gr_lims(zaxis, true)
|
||||||
clims = sp[:clims]
|
clims = sp[:clims]
|
||||||
if is_2tuple(clims)
|
if is_2tuple(clims)
|
||||||
@ -886,7 +889,8 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
round(Int, blue(c) * 255) << 16 +
|
round(Int, blue(c) * 255) << 16 +
|
||||||
round(Int, green(c) * 255) << 8 +
|
round(Int, green(c) * 255) << 8 +
|
||||||
round(Int, red(c) * 255) ), colors)
|
round(Int, red(c) * 255) ), colors)
|
||||||
GR.drawimage(xmin, xmax, ymax, ymin, length(x), length(y), rgba)
|
w, h = length(x), length(y)
|
||||||
|
GR.drawimage(xmin, xmax, ymax, ymin, w, h, rgba)
|
||||||
cmap && gr_colorbar(sp)
|
cmap && gr_colorbar(sp)
|
||||||
|
|
||||||
elseif st in (:path3d, :scatter3d)
|
elseif st in (:path3d, :scatter3d)
|
||||||
|
|||||||
@ -435,6 +435,7 @@ function plotly_series(plt::Plot, series::Series)
|
|||||||
isscatter = st in (:scatter, :scatter3d, :scattergl)
|
isscatter = st in (:scatter, :scatter3d, :scattergl)
|
||||||
hasmarker = isscatter || series[:markershape] != :none
|
hasmarker = isscatter || series[:markershape] != :none
|
||||||
hasline = st in (:path, :path3d)
|
hasline = st in (:path, :path3d)
|
||||||
|
hasfillrange = st in (:path, :scatter, :scattergl) && isa(series[:fillrange], AbstractVector)
|
||||||
|
|
||||||
# for surface types, set the data
|
# for surface types, set the data
|
||||||
if st in (:heatmap, :contour, :surface, :wireframe)
|
if st in (:heatmap, :contour, :surface, :wireframe)
|
||||||
@ -461,8 +462,11 @@ function plotly_series(plt::Plot, series::Series)
|
|||||||
if series[:fillrange] == true || series[:fillrange] == 0
|
if series[:fillrange] == true || series[:fillrange] == 0
|
||||||
d_out[:fill] = "tozeroy"
|
d_out[:fill] = "tozeroy"
|
||||||
d_out[:fillcolor] = rgba_string(series[:fillcolor])
|
d_out[:fillcolor] = rgba_string(series[:fillcolor])
|
||||||
|
elseif isa(series[:fillrange], AbstractVector)
|
||||||
|
d_out[:fill] = "tonexty"
|
||||||
|
d_out[:fillcolor] = rgba_string(series[:fillcolor])
|
||||||
elseif !(series[:fillrange] in (false, nothing))
|
elseif !(series[:fillrange] in (false, nothing))
|
||||||
warn("fillrange ignored... plotly only supports filling to zero. fillrange: $(series[:fillrange])")
|
warn("fillrange ignored... plotly only supports filling to zero and to a vector of values. fillrange: $(series[:fillrange])")
|
||||||
end
|
end
|
||||||
d_out[:x], d_out[:y] = x, y
|
d_out[:x], d_out[:y] = x, y
|
||||||
|
|
||||||
@ -479,6 +483,7 @@ function plotly_series(plt::Plot, series::Series)
|
|||||||
d_out[:type] = "heatmap"
|
d_out[:type] = "heatmap"
|
||||||
# d_out[:x], d_out[:y], d_out[:z] = series[:x], series[:y], transpose_z(series, series[:z].surf, false)
|
# d_out[:x], d_out[:y], d_out[:z] = series[:x], series[:y], transpose_z(series, series[:z].surf, false)
|
||||||
d_out[:colorscale] = plotly_colorscale(series[:fillcolor], series[:fillalpha])
|
d_out[:colorscale] = plotly_colorscale(series[:fillcolor], series[:fillalpha])
|
||||||
|
d_out[:showscale] = sp[:legend] != :none
|
||||||
|
|
||||||
elseif st == :contour
|
elseif st == :contour
|
||||||
d_out[:type] = "contour"
|
d_out[:type] = "contour"
|
||||||
@ -487,6 +492,7 @@ function plotly_series(plt::Plot, series::Series)
|
|||||||
d_out[:ncontours] = series[:levels]
|
d_out[:ncontours] = series[:levels]
|
||||||
d_out[:contours] = KW(:coloring => series[:fillrange] != nothing ? "fill" : "lines")
|
d_out[:contours] = KW(:coloring => series[:fillrange] != nothing ? "fill" : "lines")
|
||||||
d_out[:colorscale] = plotly_colorscale(series[:linecolor], series[:linealpha])
|
d_out[:colorscale] = plotly_colorscale(series[:linecolor], series[:linealpha])
|
||||||
|
d_out[:showscale] = sp[:legend] != :none
|
||||||
|
|
||||||
elseif st in (:surface, :wireframe)
|
elseif st in (:surface, :wireframe)
|
||||||
d_out[:type] = "surface"
|
d_out[:type] = "surface"
|
||||||
@ -499,11 +505,13 @@ function plotly_series(plt::Plot, series::Series)
|
|||||||
:highlightwidth => series[:linewidth],
|
:highlightwidth => series[:linewidth],
|
||||||
)
|
)
|
||||||
d_out[:contours] = KW(:x => wirelines, :y => wirelines, :z => wirelines)
|
d_out[:contours] = KW(:x => wirelines, :y => wirelines, :z => wirelines)
|
||||||
|
d_out[:showscale] = false
|
||||||
else
|
else
|
||||||
d_out[:colorscale] = plotly_colorscale(series[:fillcolor], series[:fillalpha])
|
d_out[:colorscale] = plotly_colorscale(series[:fillcolor], series[:fillalpha])
|
||||||
if series[:fill_z] != nothing
|
if series[:fill_z] != nothing
|
||||||
d_out[:surfacecolor] = plotly_surface_data(series, series[:fill_z])
|
d_out[:surfacecolor] = plotly_surface_data(series, series[:fill_z])
|
||||||
end
|
end
|
||||||
|
d_out[:showscale] = sp[:legend] != :none
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif st == :pie
|
elseif st == :pie
|
||||||
@ -572,7 +580,19 @@ function plotly_series(plt::Plot, series::Series)
|
|||||||
plotly_polar!(d_out, series)
|
plotly_polar!(d_out, series)
|
||||||
plotly_hover!(d_out, series[:hover])
|
plotly_hover!(d_out, series[:hover])
|
||||||
|
|
||||||
[d_out]
|
if hasfillrange
|
||||||
|
# if hasfillrange is true, return two dictionaries (one for original
|
||||||
|
# series, one for series being filled to) instead of one
|
||||||
|
d_out_fillrange = copy(d_out)
|
||||||
|
d_out_fillrange[:y] = series[:fillrange]
|
||||||
|
d_out_fillrange[:showlegend] = false
|
||||||
|
delete!(d_out_fillrange, :fill)
|
||||||
|
delete!(d_out_fillrange, :fillcolor)
|
||||||
|
|
||||||
|
return [d_out_fillrange, d_out]
|
||||||
|
else
|
||||||
|
return [d_out]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function plotly_series_shapes(plt::Plot, series::Series)
|
function plotly_series_shapes(plt::Plot, series::Series)
|
||||||
|
|||||||
@ -926,7 +926,7 @@ function py_compute_axis_minval(axis::Axis)
|
|||||||
for series in series_list(sp)
|
for series in series_list(sp)
|
||||||
v = series.d[axis[:letter]]
|
v = series.d[axis[:letter]]
|
||||||
if !isempty(v)
|
if !isempty(v)
|
||||||
minval = NaNMath.min(minval, ignorenan_minimum(abs(v)))
|
minval = NaNMath.min(minval, ignorenan_minimum(abs.(v)))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -703,7 +703,7 @@ end
|
|||||||
|
|
||||||
function error_coords(xorig, yorig, ebar)
|
function error_coords(xorig, yorig, ebar)
|
||||||
# init empty x/y, and zip errors if passed Tuple{Vector,Vector}
|
# init empty x/y, and zip errors if passed Tuple{Vector,Vector}
|
||||||
x, y = Array(float_extended_type(xorig), 0), Array(Float64, 0)
|
x, y = Array{float_extended_type(xorig)}(0), Array{Float64}(0)
|
||||||
# for each point, create a line segment from the bottom to the top of the errorbar
|
# for each point, create a line segment from the bottom to the top of the errorbar
|
||||||
for i = 1:max(length(xorig), length(yorig))
|
for i = 1:max(length(xorig), length(yorig))
|
||||||
xi = _cycle(xorig, i)
|
xi = _cycle(xorig, i)
|
||||||
@ -970,11 +970,11 @@ abline!(args...; kw...) = abline!(current(), args...; kw...)
|
|||||||
# -------------------------------------------------
|
# -------------------------------------------------
|
||||||
# Dates
|
# Dates
|
||||||
|
|
||||||
dateformatter(dt) = string(convert(Date, dt))
|
dateformatter(dt) = string(Date(Dates.UTD(dt)))
|
||||||
datetimeformatter(dt) = string(convert(DateTime, dt))
|
datetimeformatter(dt) = string(DateTime(Dates.UTM(dt)))
|
||||||
|
|
||||||
@recipe f(::Type{Date}, dt::Date) = (dt -> convert(Int, dt), dateformatter)
|
@recipe f(::Type{Date}, dt::Date) = (dt -> Dates.value(dt), dateformatter)
|
||||||
@recipe f(::Type{DateTime}, dt::DateTime) = (dt -> convert(Int, dt), datetimeformatter)
|
@recipe f(::Type{DateTime}, dt::DateTime) = (dt -> Dates.value(dt), datetimeformatter)
|
||||||
|
|
||||||
# -------------------------------------------------
|
# -------------------------------------------------
|
||||||
# Complex Numbers
|
# Complex Numbers
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user