Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fe21c4de89 | |||
| 8dd2a7d099 | |||
| 14e78e7235 | |||
| 7fe6a69a21 | |||
| 60dcfa9a90 | |||
| 3d2f7571a0 | |||
| 86c26085b3 | |||
| 2d5ad2828b | |||
| bae04d05a3 | |||
| bd287f4656 | |||
| 638fe6d245 | |||
| 3f05dc3570 | |||
| 44150ccbe4 | |||
| c15483d593 | |||
| 363f401474 | |||
| a532c97ce2 | |||
| df07dc9377 | |||
| 9cf9edffe0 |
+1
-1
@@ -1,7 +1,7 @@
|
||||
name = "Plots"
|
||||
uuid = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
|
||||
author = ["Tom Breloff (@tbreloff)"]
|
||||
version = "1.6.10"
|
||||
version = "1.6.12"
|
||||
|
||||
[deps]
|
||||
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
|
||||
|
||||
@@ -226,7 +226,6 @@ function _precompile_()
|
||||
Base.precompile(Tuple{typeof(Plots.slice_arg),Array{Symbol,2},Int64})
|
||||
Base.precompile(Tuple{typeof(Plots.slice_arg),Base.ReshapedArray{Int64,2,UnitRange{Int64},Tuple{}},Int64})
|
||||
Base.precompile(Tuple{typeof(Plots.straightline_data),Tuple{Float64,Float64},Tuple{Float64,Float64},Array{Float64,1},Array{Float64,1},Int64})
|
||||
Base.precompile(Tuple{typeof(Plots.transpose_z),Plots.Series,Array{Float64,2},Bool})
|
||||
Base.precompile(Tuple{typeof(RecipesBase.apply_recipe),Dict{Symbol,Any},Array{Complex{Float64},1}})
|
||||
Base.precompile(Tuple{typeof(RecipesBase.apply_recipe),Dict{Symbol,Any},Array{GeometryBasics.Point{2,Float64},1}})
|
||||
Base.precompile(Tuple{typeof(RecipesBase.apply_recipe),Dict{Symbol,Any},Array{OHLC,1}})
|
||||
|
||||
@@ -315,7 +315,6 @@ function _precompile_()
|
||||
Base.precompile(Tuple{typeof(Plots.slice_arg),Array{Symbol,2},Int64})
|
||||
Base.precompile(Tuple{typeof(Plots.slice_arg),Base.ReshapedArray{Int64,2,UnitRange{Int64},Tuple{}},Int64})
|
||||
Base.precompile(Tuple{typeof(Plots.straightline_data),Tuple{Float64,Float64},Tuple{Float64,Float64},Array{Float64,1},Array{Float64,1},Int64})
|
||||
Base.precompile(Tuple{typeof(Plots.transpose_z),Plots.Series,Array{Float64,2},Bool})
|
||||
Base.precompile(Tuple{typeof(RecipesBase.apply_recipe),Dict{Symbol,Any},Array{Complex{Float64},1}})
|
||||
Base.precompile(Tuple{typeof(RecipesBase.apply_recipe),Dict{Symbol,Any},Array{GeometryBasics.Point{2,Float64},1}})
|
||||
Base.precompile(Tuple{typeof(RecipesBase.apply_recipe),Dict{Symbol,Any},Array{OHLC,1}})
|
||||
|
||||
@@ -291,7 +291,6 @@ function _precompile_()
|
||||
Base.precompile(Tuple{typeof(Plots.slice_arg),Array{Symbol,2},Int64})
|
||||
Base.precompile(Tuple{typeof(Plots.slice_arg),Base.ReshapedArray{Int64,2,UnitRange{Int64},Tuple{}},Int64})
|
||||
Base.precompile(Tuple{typeof(Plots.straightline_data),Tuple{Float64,Float64},Tuple{Float64,Float64},Array{Float64,1},Array{Float64,1},Int64})
|
||||
Base.precompile(Tuple{typeof(Plots.transpose_z),Plots.Series,Array{Float64,2},Bool})
|
||||
Base.precompile(Tuple{typeof(RecipesBase.apply_recipe),Dict{Symbol,Any},Array{Complex{Float64},1}})
|
||||
Base.precompile(Tuple{typeof(RecipesBase.apply_recipe),Dict{Symbol,Any},Array{GeometryBasics.Point{2,Float64},1}})
|
||||
Base.precompile(Tuple{typeof(RecipesBase.apply_recipe),Dict{Symbol,Any},Array{OHLC,1}})
|
||||
|
||||
@@ -227,7 +227,6 @@ function _precompile_()
|
||||
Base.precompile(Tuple{typeof(Plots.slice_arg),Array{Symbol,2},Int64})
|
||||
Base.precompile(Tuple{typeof(Plots.slice_arg),Base.ReshapedArray{Int64,2,UnitRange{Int64},Tuple{}},Int64})
|
||||
Base.precompile(Tuple{typeof(Plots.straightline_data),Tuple{Float64,Float64},Tuple{Float64,Float64},Array{Float64,1},Array{Float64,1},Int64})
|
||||
Base.precompile(Tuple{typeof(Plots.transpose_z),Plots.Series,Array{Float64,2},Bool})
|
||||
Base.precompile(Tuple{typeof(RecipesBase.apply_recipe),Dict{Symbol,Any},Array{Complex{Float64},1}})
|
||||
Base.precompile(Tuple{typeof(RecipesBase.apply_recipe),Dict{Symbol,Any},Array{GeometryBasics.Point{2,Float64},1}})
|
||||
Base.precompile(Tuple{typeof(RecipesBase.apply_recipe),Dict{Symbol,Any},Array{OHLC,1}})
|
||||
|
||||
@@ -285,7 +285,6 @@ function _precompile_()
|
||||
Base.precompile(Tuple{typeof(Plots.slice_arg),Array{Symbol,2},Int64})
|
||||
Base.precompile(Tuple{typeof(Plots.slice_arg),Base.ReshapedArray{Int64,2,UnitRange{Int64},Tuple{}},Int64})
|
||||
Base.precompile(Tuple{typeof(Plots.straightline_data),Tuple{Float64,Float64},Tuple{Float64,Float64},Array{Float64,1},Array{Float64,1},Int64})
|
||||
Base.precompile(Tuple{typeof(Plots.transpose_z),Plots.Series,Array{Float64,2},Bool})
|
||||
Base.precompile(Tuple{typeof(RecipesBase.apply_recipe),Dict{Symbol,Any},Array{Complex{Float64},1}})
|
||||
Base.precompile(Tuple{typeof(RecipesBase.apply_recipe),Dict{Symbol,Any},Array{GeometryBasics.Point{2,Float64},1}})
|
||||
Base.precompile(Tuple{typeof(RecipesBase.apply_recipe),Dict{Symbol,Any},Array{OHLC,1}})
|
||||
|
||||
@@ -285,7 +285,6 @@ function _precompile_()
|
||||
Base.precompile(Tuple{typeof(Plots.slice_arg),Array{Symbol,2},Int64})
|
||||
Base.precompile(Tuple{typeof(Plots.slice_arg),Base.ReshapedArray{Int64,2,UnitRange{Int64},Tuple{}},Int64})
|
||||
Base.precompile(Tuple{typeof(Plots.straightline_data),Tuple{Float64,Float64},Tuple{Float64,Float64},Array{Float64,1},Array{Float64,1},Int64})
|
||||
Base.precompile(Tuple{typeof(Plots.transpose_z),Plots.Series,Array{Float64,2},Bool})
|
||||
Base.precompile(Tuple{typeof(RecipesBase.apply_recipe),Dict{Symbol,Any},Array{Complex{Float64},1}})
|
||||
Base.precompile(Tuple{typeof(RecipesBase.apply_recipe),Dict{Symbol,Any},Array{GeometryBasics.Point{2,Float64},1}})
|
||||
Base.precompile(Tuple{typeof(RecipesBase.apply_recipe),Dict{Symbol,Any},Array{OHLC,1}})
|
||||
|
||||
@@ -226,7 +226,6 @@ function _precompile_()
|
||||
Base.precompile(Tuple{typeof(Plots.slice_arg),Array{Symbol,2},Int64})
|
||||
Base.precompile(Tuple{typeof(Plots.slice_arg),Base.ReshapedArray{Int64,2,UnitRange{Int64},Tuple{}},Int64})
|
||||
Base.precompile(Tuple{typeof(Plots.straightline_data),Tuple{Float64,Float64},Tuple{Float64,Float64},Array{Float64,1},Array{Float64,1},Int64})
|
||||
Base.precompile(Tuple{typeof(Plots.transpose_z),Plots.Series,Array{Float64,2},Bool})
|
||||
Base.precompile(Tuple{typeof(RecipesBase.apply_recipe),Dict{Symbol,Any},Array{Complex{Float64},1}})
|
||||
Base.precompile(Tuple{typeof(RecipesBase.apply_recipe),Dict{Symbol,Any},Array{GeometryBasics.Point{2,Float64},1}})
|
||||
Base.precompile(Tuple{typeof(RecipesBase.apply_recipe),Dict{Symbol,Any},Array{OHLC,1}})
|
||||
|
||||
@@ -317,7 +317,6 @@ function _precompile_()
|
||||
Base.precompile(Tuple{typeof(Plots.slice_arg),Array{Symbol,2},Int64})
|
||||
Base.precompile(Tuple{typeof(Plots.slice_arg),Base.ReshapedArray{Int64,2,UnitRange{Int64},Tuple{}},Int64})
|
||||
Base.precompile(Tuple{typeof(Plots.straightline_data),Tuple{Float64,Float64},Tuple{Float64,Float64},Array{Float64,1},Array{Float64,1},Int64})
|
||||
Base.precompile(Tuple{typeof(Plots.transpose_z),Plots.Series,Array{Float64,2},Bool})
|
||||
Base.precompile(Tuple{typeof(RecipesBase.apply_recipe),Dict{Symbol,Any},Array{Complex{Float64},1}})
|
||||
Base.precompile(Tuple{typeof(RecipesBase.apply_recipe),Dict{Symbol,Any},Array{GeometryBasics.Point{2,Float64},1}})
|
||||
Base.precompile(Tuple{typeof(RecipesBase.apply_recipe),Dict{Symbol,Any},Array{OHLC,1}})
|
||||
|
||||
@@ -286,7 +286,6 @@ function _precompile_()
|
||||
Base.precompile(Tuple{typeof(Plots.slice_arg),Array{Symbol,2},Int64})
|
||||
Base.precompile(Tuple{typeof(Plots.slice_arg),Base.ReshapedArray{Int64,2,UnitRange{Int64},Tuple{}},Int64})
|
||||
Base.precompile(Tuple{typeof(Plots.straightline_data),Tuple{Float64,Float64},Tuple{Float64,Float64},Array{Float64,1},Array{Float64,1},Int64})
|
||||
Base.precompile(Tuple{typeof(Plots.transpose_z),Plots.Series,Array{Float64,2},Bool})
|
||||
Base.precompile(Tuple{typeof(RecipesBase.apply_recipe),Dict{Symbol,Any},Array{Complex{Float64},1}})
|
||||
Base.precompile(Tuple{typeof(RecipesBase.apply_recipe),Dict{Symbol,Any},Array{GeometryBasics.Point{2,Float64},1}})
|
||||
Base.precompile(Tuple{typeof(RecipesBase.apply_recipe),Dict{Symbol,Any},Array{OHLC,1}})
|
||||
|
||||
+1
-1
@@ -189,9 +189,9 @@ import RecipesPipeline: SliceIt,
|
||||
|
||||
include("types.jl")
|
||||
include("utils.jl")
|
||||
include("components.jl")
|
||||
include("axes.jl")
|
||||
include("args.jl")
|
||||
include("components.jl")
|
||||
include("themes.jl")
|
||||
include("plot.jl")
|
||||
include("pipeline.jl")
|
||||
|
||||
+123
-14
@@ -1,21 +1,34 @@
|
||||
function makeplural(s::Symbol)
|
||||
str = string(s)
|
||||
if last(str) != 's'
|
||||
return Symbol(string(s,"s"))
|
||||
end
|
||||
return s
|
||||
end
|
||||
|
||||
function make_non_underscore(s::Symbol)
|
||||
str = string(s)
|
||||
str = replace(str, "_" => "")
|
||||
return Symbol(str)
|
||||
end
|
||||
|
||||
const _keyAliases = Dict{Symbol,Symbol}()
|
||||
|
||||
function add_aliases(sym::Symbol, aliases::Symbol...)
|
||||
for alias in aliases
|
||||
if haskey(_keyAliases, alias)
|
||||
error("Already an alias $alias => $(_keyAliases[alias])... can't also alias $sym")
|
||||
if haskey(_keyAliases, alias) || alias === sym
|
||||
return nothing
|
||||
end
|
||||
_keyAliases[alias] = sym
|
||||
end
|
||||
return nothing
|
||||
end
|
||||
|
||||
function add_non_underscore_aliases!(aliases::Dict{Symbol,Symbol})
|
||||
for (k,v) in aliases
|
||||
s = string(k)
|
||||
if '_' in s
|
||||
aliases[Symbol(replace(s, "_" => ""))] = v
|
||||
aliases[make_non_underscore(k)] = v
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -24,7 +37,7 @@ function add_non_underscore_aliases!(aliases::Dict{Symbol,Symbol}, args::Vector{
|
||||
for arg in args
|
||||
s = string(arg)
|
||||
if '_' in s
|
||||
aliases[Symbol(replace(s, "_" => ""))] = arg
|
||||
aliases[make_non_underscore(arg)] = arg
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -111,6 +124,31 @@ const _styleAliases = Dict{Symbol,Symbol}(
|
||||
:ddd => :dashdotdot,
|
||||
)
|
||||
|
||||
const _shape_keys = Symbol[
|
||||
:circle,
|
||||
:rect,
|
||||
:star5,
|
||||
:diamond,
|
||||
:hexagon,
|
||||
:cross,
|
||||
:xcross,
|
||||
:utriangle,
|
||||
:dtriangle,
|
||||
:rtriangle,
|
||||
:ltriangle,
|
||||
:pentagon,
|
||||
:heptagon,
|
||||
:octagon,
|
||||
:star4,
|
||||
:star6,
|
||||
:star7,
|
||||
:star8,
|
||||
:vline,
|
||||
:hline,
|
||||
:+,
|
||||
:x,
|
||||
]
|
||||
|
||||
const _allMarkers = vcat(:none, :auto, _shape_keys) #sort(collect(keys(_shapes))))
|
||||
const _markerAliases = Dict{Symbol,Symbol}(
|
||||
:n => :none,
|
||||
@@ -280,8 +318,6 @@ const _series_defaults = KW(
|
||||
:show_empty_bins => false, # should empty bins in 2D histogram be colored as zero (otherwise they are transparent)
|
||||
:contours => false, # add contours to 3d surface and wireframe plots
|
||||
:contour_labels => false,
|
||||
:match_dimensions => false, # do rows match x (true) or y (false) for heatmap/image/spy? see issue 196
|
||||
# this ONLY effects whether or not the z-matrix is transposed for a heatmap display!
|
||||
:subplot => :auto, # which subplot(s) does this series belong to?
|
||||
:series_annotations => nothing, # a list of annotations which apply to the coordinates of this series
|
||||
:primary => true, # when true, this "counts" as a series for color selection, etc. the main use is to allow
|
||||
@@ -493,7 +529,7 @@ const _all_series_args = sort(union([_series_args; _magic_series_args]))
|
||||
const _all_plot_args = _plot_args
|
||||
|
||||
const _all_args =
|
||||
sort([_all_axis_args; _all_subplot_args; _all_series_args; _all_plot_args])
|
||||
sort(union([_all_axis_args; _all_subplot_args; _all_series_args; _all_plot_args]))
|
||||
|
||||
is_subplot_attr(k) = k in _all_subplot_args
|
||||
is_series_attr(k) = k in _all_series_args
|
||||
@@ -504,9 +540,6 @@ RecipesBase.is_key_supported(k::Symbol) = is_attr_supported(k)
|
||||
is_default_attribute(k) = k in _internal_args || k in _all_args || is_axis_attr_noletter(k)
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
makeplural(s::Symbol) = Symbol(string(s,"s"))
|
||||
|
||||
autopick_ignore_none_auto(arr::AVec, idx::Integer) = _cycle(setdiff(arr, [:none, :auto]), idx)
|
||||
autopick_ignore_none_auto(notarr, idx::Integer) = notarr
|
||||
|
||||
@@ -629,7 +662,6 @@ add_aliases(:quiver, :velocity, :quiver2d, :gradient, :vectorfield)
|
||||
add_aliases(:normalize, :norm, :normed, :normalized)
|
||||
add_aliases(:show_empty_bins, :showemptybins, :showempty, :show_empty)
|
||||
add_aliases(:aspect_ratio, :aspectratio, :axis_ratio, :axisratio, :ratio)
|
||||
add_aliases(:match_dimensions, :transpose, :transpose_z)
|
||||
add_aliases(:subplot, :sp, :subplt, :splt)
|
||||
add_aliases(:projection, :proj)
|
||||
add_aliases(:titlelocation, :title_location, :title_loc, :titleloc, :title_position, :title_pos, :titlepos, :titleposition, :title_align, :title_alignment)
|
||||
@@ -649,10 +681,10 @@ add_aliases(:contour_labels, :contourlabels, :clabels, :clabs)
|
||||
add_aliases(:warn_on_unsupported, :warn)
|
||||
|
||||
# add all pluralized forms to the _keyAliases dict
|
||||
for arg in keys(_series_defaults)
|
||||
_keyAliases[makeplural(arg)] = arg
|
||||
for arg in _all_args
|
||||
add_aliases(arg, makeplural(arg))
|
||||
end
|
||||
|
||||
# add all non_underscored forms to the _keyAliases
|
||||
add_non_underscore_aliases!(_keyAliases)
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
@@ -1700,3 +1732,80 @@ function _series_index(plotattributes, sp)
|
||||
end
|
||||
return idx
|
||||
end
|
||||
|
||||
#--------------------------------------------------
|
||||
## inspired by Base.@kwdef
|
||||
macro add_attributes( level, expr )
|
||||
expr = macroexpand(__module__, expr) # to expand @static
|
||||
expr isa Expr && expr.head === :struct || error("Invalid usage of @add_attributes")
|
||||
T = expr.args[2]
|
||||
if T isa Expr && T.head === :<:
|
||||
T = T.args[1]
|
||||
end
|
||||
|
||||
key_args = Any[]
|
||||
value_args = Any[]
|
||||
|
||||
_splitdef!(expr.args[3], value_args, key_args)
|
||||
|
||||
insert_block = Expr(:block)
|
||||
for (key, value) in zip(key_args, value_args)
|
||||
# e.g. _series_defualts[key] = value
|
||||
exp_key = Symbol(lowercase(string(T)), "_", key)
|
||||
pl_key = makeplural(exp_key)
|
||||
push!(insert_block.args, Expr(
|
||||
:(=), Expr(:ref, Symbol("_", level, "_defaults"), QuoteNode(exp_key)), value
|
||||
))
|
||||
push!(insert_block.args, :(
|
||||
add_aliases($(QuoteNode(exp_key)), $(QuoteNode(pl_key)))
|
||||
))
|
||||
push!(insert_block.args, :(
|
||||
add_aliases($(QuoteNode(exp_key)), $(QuoteNode(make_non_underscore(exp_key))))
|
||||
))
|
||||
push!(insert_block.args, :(
|
||||
add_aliases($(QuoteNode(exp_key)), $(QuoteNode(make_non_underscore(pl_key))))
|
||||
))
|
||||
end
|
||||
return quote
|
||||
$expr
|
||||
$insert_block
|
||||
end |> esc
|
||||
end
|
||||
|
||||
function _splitdef!(blk, value_args, key_args)
|
||||
for i in eachindex(blk.args)
|
||||
ei = blk.args[i]
|
||||
if ei isa Symbol
|
||||
# var
|
||||
continue
|
||||
elseif ei isa Expr
|
||||
if ei.head === :(=)
|
||||
lhs = ei.args[1]
|
||||
if lhs isa Symbol
|
||||
# var = defexpr
|
||||
var = lhs
|
||||
elseif lhs isa Expr && lhs.head === :(::) && lhs.args[1] isa Symbol
|
||||
# var::T = defexpr
|
||||
var = lhs.args[1]
|
||||
else
|
||||
# something else, e.g. inline inner constructor
|
||||
# F(...) = ...
|
||||
continue
|
||||
end
|
||||
defexpr = ei.args[2] # defexpr
|
||||
push!(value_args, defexpr)
|
||||
push!(key_args, var)
|
||||
blk.args[i] = lhs
|
||||
elseif ei.head === :(::) && ei.args[1] isa Symbol
|
||||
# var::Typ
|
||||
var = ei.args[1]
|
||||
push!(value_args, var)
|
||||
push!(key_args, var)
|
||||
elseif ei.head === :block
|
||||
# can arise with use of @static inside type decl
|
||||
_kwdef!(ei, value_args, key_args)
|
||||
end
|
||||
end
|
||||
end
|
||||
blk
|
||||
end
|
||||
|
||||
@@ -316,7 +316,6 @@ const _gr_attr = merge_with_base_supported([
|
||||
:layout,
|
||||
:title, :window_title,
|
||||
:guide, :lims, :ticks, :scale, :flip,
|
||||
:match_dimensions,
|
||||
:titlefontfamily, :titlefontsize, :titlefonthalign, :titlefontvalign,
|
||||
:titlefontrotation, :titlefontcolor,
|
||||
:legendfontfamily, :legendfontsize, :legendfonthalign, :legendfontvalign,
|
||||
@@ -472,7 +471,6 @@ const _pgfplots_attr = merge_with_base_supported([
|
||||
:polar,
|
||||
# :normalize, :weights, :contours,
|
||||
:aspect_ratio,
|
||||
# :match_dimensions,
|
||||
:tick_direction,
|
||||
:framestyle,
|
||||
:camera,
|
||||
@@ -541,7 +539,6 @@ const _pyplot_attr = merge_with_base_supported([
|
||||
:polar,
|
||||
:normalize, :weights,
|
||||
:contours, :aspect_ratio,
|
||||
:match_dimensions,
|
||||
:clims,
|
||||
:inset_subplots,
|
||||
:dpi,
|
||||
@@ -627,7 +624,6 @@ const _hdf5_attr = merge_with_base_supported([
|
||||
:polar,
|
||||
:normalize, :weights,
|
||||
:contours, :aspect_ratio,
|
||||
:match_dimensions,
|
||||
:clims,
|
||||
:inset_subplots,
|
||||
:dpi,
|
||||
@@ -700,7 +696,6 @@ const _inspectdr_attr = merge_with_base_supported([
|
||||
:polar,
|
||||
# :normalize, :weights,
|
||||
# :contours, :aspect_ratio,
|
||||
:match_dimensions,
|
||||
# :clims,
|
||||
# :inset_subplots,
|
||||
:dpi,
|
||||
@@ -761,7 +756,6 @@ const _pgfplotsx_attr = merge_with_base_supported([
|
||||
:ticks,
|
||||
:scale,
|
||||
:flip,
|
||||
:match_dimensions,
|
||||
:titlefontfamily,
|
||||
:titlefontsize,
|
||||
:titlefonthalign,
|
||||
|
||||
+3
-6
@@ -1488,14 +1488,12 @@ function gr_add_series(sp, series)
|
||||
|
||||
GR.savestate()
|
||||
|
||||
x, y, z = series[:x], series[:y], series[:z]
|
||||
x, y, z = (handle_surface(series[letter]) for letter in (:x, :y, :z))
|
||||
xscale, yscale = sp[:xaxis][:scale], sp[:yaxis][:scale]
|
||||
frng = series[:fillrange]
|
||||
|
||||
# recompute data
|
||||
if typeof(z) <: Surface
|
||||
z = transpose_z(series, z.surf, false)
|
||||
elseif ispolar(sp)
|
||||
if ispolar(sp) && z === nothing
|
||||
rmin, rmax = axis_limits(sp, :y)
|
||||
if frng !== nothing
|
||||
_, frng = convert_to_polar(x, frng, (rmin, rmax))
|
||||
@@ -1735,7 +1733,7 @@ function gr_draw_heatmap(series, x, y, z, clims)
|
||||
else
|
||||
phimin, phimax = 0.0, 360.0 # nonuniform polar array is not yet supported in GR.jl
|
||||
nx, ny = length(series[:x]), length(series[:y])
|
||||
xmin, xmax, ymin, ymax = gr_xy_axislims(sp)
|
||||
xmin, xmax, ymin, ymax = gr_xy_axislims(series[:subplot])
|
||||
GR.setwindow(-ymax, ymax, -ymax, ymax)
|
||||
if ymin > 0
|
||||
@warn "'ymin[1] > 0' (rmin) is not yet supported."
|
||||
@@ -1752,7 +1750,6 @@ function gr_draw_heatmap(series, x, y, z, clims)
|
||||
end
|
||||
|
||||
function gr_draw_image(series, x, y, z, clims)
|
||||
z = transpose_z(series, series[:z].surf, true)'
|
||||
w, h = size(z)
|
||||
xmin, xmax = ignorenan_extrema(x)
|
||||
ymin, ymax = ignorenan_extrema(y)
|
||||
|
||||
@@ -646,7 +646,7 @@ pgfx_series_arguments(series, opt, range) = (arg[range] for arg in pgfx_series_a
|
||||
function pgfx_series_arguments(series, opt)
|
||||
st = series[:seriestype]
|
||||
return if st in (:contour, :contour3d)
|
||||
opt[:x], opt[:y], Array(opt[:z])'
|
||||
opt[:x], opt[:y], handle_surface(opt[:z])
|
||||
elseif st in (:heatmap, :surface, :wireframe)
|
||||
surface_to_vecs(opt[:x], opt[:y], opt[:z])
|
||||
elseif RecipesPipeline.is3d(st)
|
||||
|
||||
@@ -459,7 +459,7 @@ function plotly_data(series::Series, letter::Symbol, data)
|
||||
end
|
||||
|
||||
if series[:seriestype] in (:heatmap, :contour, :surface, :wireframe, :mesh3d)
|
||||
plotly_surface_data(series, data)
|
||||
handle_surface(data)
|
||||
else
|
||||
plotly_data(data)
|
||||
end
|
||||
@@ -469,10 +469,6 @@ plotly_data(v::AbstractArray) = v
|
||||
plotly_data(surf::Surface) = surf.surf
|
||||
plotly_data(v::AbstractArray{R}) where {R<:Rational} = float(v)
|
||||
|
||||
plotly_surface_data(series::Series, a::AbstractVector) = a
|
||||
plotly_surface_data(series::Series, a::AbstractMatrix) = transpose_z(series, a, false)
|
||||
plotly_surface_data(series::Series, a::Surface) = plotly_surface_data(series, a.surf)
|
||||
|
||||
function plotly_native_data(axis::Axis, data::AbstractArray)
|
||||
if !isempty(axis[:discrete_values])
|
||||
construct_categorical_data(data, axis)
|
||||
@@ -588,7 +584,7 @@ function plotly_series(plt::Plot, series::Series)
|
||||
plotattributes_out[:colorscale] = plotly_colorscale(series[:fillcolor], series[:fillalpha])
|
||||
plotattributes_out[:opacity] = series[:fillalpha]
|
||||
if series[:fill_z] !== nothing
|
||||
plotattributes_out[:surfacecolor] = plotly_surface_data(series, series[:fill_z])
|
||||
plotattributes_out[:surfacecolor] = handle_surface(series[:fill_z])
|
||||
end
|
||||
plotattributes_out[:showscale] = hascolorbar(sp)
|
||||
end
|
||||
@@ -613,7 +609,7 @@ function plotly_series(plt::Plot, series::Series)
|
||||
plotattributes_out[:color] = rgba_string(plot_color(series[:fillcolor], series[:fillalpha]))
|
||||
plotattributes_out[:opacity] = series[:fillalpha]
|
||||
if series[:fill_z] !== nothing
|
||||
plotattributes_out[:surfacecolor] = plotly_surface_data(series, series[:fill_z])
|
||||
plotattributes_out[:surfacecolor] = handle_surface(series[:fill_z])
|
||||
end
|
||||
plotattributes_out[:showscale] = hascolorbar(sp)
|
||||
else
|
||||
|
||||
+21
-23
@@ -61,6 +61,9 @@ end
|
||||
# # anything else just gets a bluesred gradient
|
||||
# py_colormap(c, α=nothing) = py_colormap(default_gradient(), α)
|
||||
|
||||
py_handle_surface(v) = v
|
||||
py_handle_surface(z::Surface) = z.surf
|
||||
|
||||
py_color(s) = py_color(parse(Colorant, string(s)))
|
||||
py_color(c::Colorant) = (red(c), green(c), blue(c), alpha(c))
|
||||
py_color(cs::AVec) = map(py_color, cs)
|
||||
@@ -344,7 +347,7 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
|
||||
fix_xy_lengths!(plt, series)
|
||||
|
||||
# ax = getAxis(plt, series)
|
||||
x, y, z = series[:x], series[:y], series[:z]
|
||||
x, y, z = (py_handle_surface(series[letter]) for letter in (:x, :y, :z))
|
||||
if st == :straightline
|
||||
x, y = straightline_data(series)
|
||||
elseif st == :shape
|
||||
@@ -512,16 +515,11 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
|
||||
end
|
||||
|
||||
if st in (:contour, :contour3d)
|
||||
z = transpose_z(series, z.surf)
|
||||
if typeof(x)<:Plots.Surface
|
||||
x = Plots.transpose_z(series, x.surf)
|
||||
end
|
||||
if typeof(y)<:Plots.Surface
|
||||
y = Plots.transpose_z(series, y.surf)
|
||||
end
|
||||
|
||||
if st == :contour3d
|
||||
extrakw[:extend3d] = true
|
||||
if !ismatrix(x) || !ismatrix(y)
|
||||
x, y = repeat(x', length(y), 1), repeat(y, 1, length(x))
|
||||
end
|
||||
end
|
||||
|
||||
if typeof(series[:linecolor]) <: AbstractArray
|
||||
@@ -556,17 +554,17 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
|
||||
end
|
||||
|
||||
if st in (:surface, :wireframe)
|
||||
if typeof(z) <: AbstractMatrix || typeof(z) <: Surface
|
||||
x, y, z = map(Array, (x,y,z))
|
||||
if z isa AbstractMatrix
|
||||
if !ismatrix(x) || !ismatrix(y)
|
||||
x = repeat(x', length(y), 1)
|
||||
y = repeat(y, 1, length(series[:x]))
|
||||
x, y = repeat(x', length(y), 1), repeat(y, 1, length(x))
|
||||
end
|
||||
z = transpose_z(series, z)
|
||||
if st == :surface
|
||||
if series[:fill_z] !== nothing
|
||||
# the surface colors are different than z-value
|
||||
extrakw[:facecolors] = py_shading(series[:fillcolor], transpose_z(series, series[:fill_z].surf))
|
||||
extrakw[:facecolors] = py_shading(
|
||||
series[:fillcolor],
|
||||
py_handle_surface(series[:fill_z]),
|
||||
)
|
||||
extrakw[:shade] = false
|
||||
else
|
||||
extrakw[:cmap] = py_fillcolormap(series)
|
||||
@@ -618,15 +616,15 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
|
||||
ymin, ymax = ignorenan_extrema(series[:y])
|
||||
dx = (xmax - xmin) / (length(series[:x]) - 1) / 2
|
||||
dy = (ymax - ymin) / (length(series[:y]) - 1) / 2
|
||||
img = Array(transpose_z(series, z.surf))
|
||||
z = if eltype(img) <: Colors.AbstractGray
|
||||
float(img)
|
||||
elseif eltype(img) <: Colorant
|
||||
map(c -> Float64[red(c),green(c),blue(c),alpha(c)], img)
|
||||
z = if eltype(z) <: Colors.AbstractGray
|
||||
float(z)
|
||||
elseif eltype(z) <: Colorant
|
||||
map(c -> Float64[red(c),green(c),blue(c),alpha(c)], z)
|
||||
else
|
||||
z # hopefully it's in a data format that will "just work" with imshow
|
||||
end
|
||||
handle = ax."imshow"(z;
|
||||
handle = ax."imshow"(
|
||||
z;
|
||||
zorder = series[:series_plotindex],
|
||||
cmap = py_colormap(cgrad(plot_color([:black, :white]))),
|
||||
vmin = 0.0,
|
||||
@@ -642,7 +640,7 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
|
||||
end
|
||||
|
||||
if st == :heatmap
|
||||
x, y, z = heatmap_edges(x, sp[:xaxis][:scale]), heatmap_edges(y, sp[:yaxis][:scale]), transpose_z(series, z.surf)
|
||||
x, y = heatmap_edges(x, sp[:xaxis][:scale], y, sp[:yaxis][:scale], size(z))
|
||||
|
||||
expand_extrema!(sp[:xaxis], x)
|
||||
expand_extrema!(sp[:yaxis], y)
|
||||
@@ -729,7 +727,7 @@ function py_set_lims(ax, sp::Subplot, axis::Axis)
|
||||
end
|
||||
|
||||
function py_surround_latextext(latexstring, env)
|
||||
if latexstring[1] == '$' && latexstring[end] == '$'
|
||||
if !isempty(latexstring) && latexstring[1] == '$' && latexstring[end] == '$'
|
||||
unenclosed = latexstring[2:end-1]
|
||||
else
|
||||
unenclosed = latexstring
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
|
||||
|
||||
const P2 = GeometryTypes.Point2{Float64}
|
||||
const P3 = GeometryTypes.Point3{Float64}
|
||||
|
||||
@@ -77,7 +75,6 @@ function weave(x,y; ordering = Vector[x,y])
|
||||
ret
|
||||
end
|
||||
|
||||
|
||||
"create a star by weaving together points from an outer and inner circle. `n` is the number of arms"
|
||||
function makestar(n; offset = -0.5, radius = 1.0)
|
||||
z1 = offset * π
|
||||
@@ -93,7 +90,6 @@ function makeshape(n; offset = -0.5, radius = 1.0)
|
||||
Shape(partialcircle(z, z + 2π, n+1, radius))
|
||||
end
|
||||
|
||||
|
||||
function makecross(; offset = -0.5, radius = 1.0)
|
||||
z2 = offset * π
|
||||
z1 = z2 - π/8
|
||||
@@ -103,7 +99,6 @@ function makecross(; offset = -0.5, radius = 1.0)
|
||||
ordering=Vector[outercircle,innercircle,outercircle]))
|
||||
end
|
||||
|
||||
|
||||
from_polar(angle, dist) = P2(dist*cos(angle), dist*sin(angle))
|
||||
|
||||
function makearrowhead(angle; h = 2.0, w = 0.4)
|
||||
@@ -112,31 +107,6 @@ function makearrowhead(angle; h = 2.0, w = 0.4)
|
||||
from_polar(angle + 0.5π, w) - tip, (0,0)])
|
||||
end
|
||||
|
||||
const _shape_keys = Symbol[
|
||||
:circle,
|
||||
:rect,
|
||||
:star5,
|
||||
:diamond,
|
||||
:hexagon,
|
||||
:cross,
|
||||
:xcross,
|
||||
:utriangle,
|
||||
:dtriangle,
|
||||
:rtriangle,
|
||||
:ltriangle,
|
||||
:pentagon,
|
||||
:heptagon,
|
||||
:octagon,
|
||||
:star4,
|
||||
:star6,
|
||||
:star7,
|
||||
:star8,
|
||||
:vline,
|
||||
:hline,
|
||||
:+,
|
||||
:x,
|
||||
]
|
||||
|
||||
const _shapes = KW(
|
||||
:circle => makeshape(20),
|
||||
:rect => makeshape(4, offset=-0.25),
|
||||
|
||||
+13
-4
@@ -1040,15 +1040,23 @@ const _examples = PlotExample[
|
||||
)
|
||||
end]
|
||||
),
|
||||
PlotExample( # 49
|
||||
"Polar heatmaps",
|
||||
"",
|
||||
[quote
|
||||
z = (1:4) .+ (1:8)'
|
||||
heatmap(z, projection = :polar)
|
||||
end]
|
||||
),
|
||||
]
|
||||
|
||||
# Some constants for PlotDocs and PlotReferenceImages
|
||||
_animation_examples = [2, 31]
|
||||
_backend_skips = Dict(
|
||||
:gr => [25, 30, 47],
|
||||
:pyplot => [2, 25, 30, 31, 47],
|
||||
:plotlyjs => [2, 21, 24, 25, 30, 31],
|
||||
:plotly => [2, 21, 24, 25, 30, 31],
|
||||
:pyplot => [2, 25, 30, 31, 47, 49],
|
||||
:plotlyjs => [2, 21, 24, 25, 30, 31, 49],
|
||||
:plotly => [2, 21, 24, 25, 30, 31, 49],
|
||||
:pgfplots => [2, 5, 6, 10, 16, 20, 22, 23, 25, 28, 30, 31, 34, 37, 38, 39, 47],
|
||||
:pgfplotsx => [
|
||||
2, # animation
|
||||
@@ -1058,7 +1066,8 @@ _backend_skips = Dict(
|
||||
30, # @df
|
||||
31, # animation
|
||||
32, # spy
|
||||
47, # mesh3
|
||||
47, # mesh3
|
||||
49, # polar heatmap
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
+3
-2
@@ -15,9 +15,10 @@ end
|
||||
function __init__()
|
||||
user_defaults = _plots_defaults()
|
||||
if haskey(user_defaults, :theme)
|
||||
theme(pop!(user_defaults, :theme))
|
||||
theme(pop!(user_defaults, :theme); user_defaults...)
|
||||
else
|
||||
default(; user_defaults...)
|
||||
end
|
||||
default(; user_defaults...)
|
||||
|
||||
insert!(Base.Multimedia.displays, findlast(x -> x isa Base.TextDisplay || x isa REPL.REPLDisplay, Base.Multimedia.displays) + 1, PlotsDisplay())
|
||||
|
||||
|
||||
+1
-1
@@ -230,7 +230,7 @@ end
|
||||
grid(args...; kw...)
|
||||
|
||||
Create a grid layout for subplots. `args` specify the dimensions, e.g.
|
||||
`grid(3,2, widths = (0.6,04))` creates a grid with three rows and two
|
||||
`grid(3,2, widths = (0.6,0.4))` creates a grid with three rows and two
|
||||
columns of different width.
|
||||
"""
|
||||
grid(args...; kw...) = GridLayout(args...; kw...)
|
||||
|
||||
+1
-3
@@ -874,9 +874,7 @@ end
|
||||
|
||||
x := Plots._bin_centers(edge_x)
|
||||
y := Plots._bin_centers(edge_y)
|
||||
z := Surface(float_weights)
|
||||
|
||||
match_dimensions := true
|
||||
z := Surface(permutedims(float_weights))
|
||||
seriestype := :heatmap
|
||||
()
|
||||
end
|
||||
|
||||
+2
-11
@@ -334,17 +334,8 @@ function indices_and_unique_values(z::AbstractArray)
|
||||
newz, vals
|
||||
end
|
||||
|
||||
# this is a helper function to determine whether we need to transpose a surface matrix.
|
||||
# it depends on whether the backend matches rows to x (transpose_on_match == true) or vice versa
|
||||
# for example: PyPlot sends rows to y, so transpose_on_match should be true
|
||||
function transpose_z(plotattributes, z, transpose_on_match::Bool = true)
|
||||
if plotattributes[:match_dimensions] == transpose_on_match
|
||||
# z'
|
||||
permutedims(z, [2,1])
|
||||
else
|
||||
z
|
||||
end
|
||||
end
|
||||
handle_surface(z) = z
|
||||
handle_surface(z::Surface) = permutedims(z.surf)
|
||||
|
||||
function ok(x::Number, y::Number, z::Number = 0)
|
||||
isfinite(x) && isfinite(y) && isfinite(z)
|
||||
|
||||
@@ -11,6 +11,7 @@ import GeometryTypes, GeometryBasics
|
||||
using Dates
|
||||
using RecipesBase
|
||||
|
||||
include("test_defaults.jl")
|
||||
include("test_axes.jl")
|
||||
include("test_axis_letter.jl")
|
||||
include("test_recipes.jl")
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
using Plots, Test
|
||||
|
||||
const PLOTS_DEFAULTS = Dict(:theme => :wong2)
|
||||
Plots.__init__()
|
||||
|
||||
@testset "Loading theme" begin
|
||||
@test plot(1:5)[1][1][:seriescolor] == RGBA(colorant"black")
|
||||
end
|
||||
|
||||
empty!(PLOTS_DEFAULTS)
|
||||
Plots.__init__()
|
||||
Reference in New Issue
Block a user