replace StaticArrays with GeometryTypes
This commit is contained in:
parent
a6e60aea04
commit
841b05631d
2
REQUIRE
2
REQUIRE
@ -4,7 +4,7 @@ RecipesBase 0.6.0
|
|||||||
PlotUtils 0.4.1
|
PlotUtils 0.4.1
|
||||||
PlotThemes 0.1.3
|
PlotThemes 0.1.3
|
||||||
Reexport
|
Reexport
|
||||||
StaticArrays 0.5
|
GeometryTypes
|
||||||
FixedPointNumbers 0.3
|
FixedPointNumbers 0.3
|
||||||
Measures
|
Measures
|
||||||
Showoff
|
Showoff
|
||||||
|
|||||||
@ -4,7 +4,7 @@ _current_plots_version = v"0.24.0"
|
|||||||
|
|
||||||
using Reexport
|
using Reexport
|
||||||
|
|
||||||
import StaticArrays
|
import GeometryTypes
|
||||||
using Dates, Printf, Statistics, Base64, LinearAlgebra, Random
|
using Dates, Printf, Statistics, Base64, LinearAlgebra, Random
|
||||||
import SparseArrays: findnz
|
import SparseArrays: findnz
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
|
|
||||||
const P2 = StaticArrays.SVector{2,Float64}
|
const P2 = GeometryTypes.Point2{Float64}
|
||||||
const P3 = StaticArrays.SVector{3,Float64}
|
const P3 = GeometryTypes.Point3{Float64}
|
||||||
|
|
||||||
nanpush!(a::AbstractVector{P2}, b) = (push!(a, P2(NaN,NaN)); push!(a, b))
|
nanpush!(a::AbstractVector{P2}, b) = (push!(a, P2(NaN,NaN)); push!(a, b))
|
||||||
nanappend!(a::AbstractVector{P2}, b) = (push!(a, P2(NaN,NaN)); append!(a, b))
|
nanappend!(a::AbstractVector{P2}, b) = (push!(a, P2(NaN,NaN)); append!(a, b))
|
||||||
@ -261,13 +261,13 @@ end
|
|||||||
Create a Font from a list of features. Values may be specified either as
|
Create a Font from a list of features. Values may be specified either as
|
||||||
arguments (which are distinguished by type/value) or as keyword arguments.
|
arguments (which are distinguished by type/value) or as keyword arguments.
|
||||||
# Arguments
|
# Arguments
|
||||||
- `family`: AbstractString. "serif" or "sans-serif" or "monospace"
|
- `family`: AbstractString. "serif" or "sans-serif" or "monospace"
|
||||||
- `pointsize`: Integer. Size of font in points
|
- `pointsize`: Integer. Size of font in points
|
||||||
- `halign`: Symbol. Horizontal alignment (:hcenter, :left, or :right)
|
- `halign`: Symbol. Horizontal alignment (:hcenter, :left, or :right)
|
||||||
- `valign`: Symbol. Vertical aligment (:vcenter, :top, or :bottom)
|
- `valign`: Symbol. Vertical aligment (:vcenter, :top, or :bottom)
|
||||||
- `rotation`: Real. Angle of rotation for text in degrees (use a non-integer type)
|
- `rotation`: Real. Angle of rotation for text in degrees (use a non-integer type)
|
||||||
- `color`: Colorant or Symbol
|
- `color`: Colorant or Symbol
|
||||||
# Examples
|
# Examples
|
||||||
```julia-repl
|
```julia-repl
|
||||||
julia> font(8)
|
julia> font(8)
|
||||||
julia> font(family="serif",halign=:center,rotation=45.0)
|
julia> font(family="serif",halign=:center,rotation=45.0)
|
||||||
@ -388,8 +388,8 @@ PlotText(str) = PlotText(string(str), font())
|
|||||||
"""
|
"""
|
||||||
text(string, args...; kw...)
|
text(string, args...; kw...)
|
||||||
|
|
||||||
Create a PlotText object wrapping a string with font info, for plot annotations.
|
Create a PlotText object wrapping a string with font info, for plot annotations.
|
||||||
`args` and `kw` are passed to `font`.
|
`args` and `kw` are passed to `font`.
|
||||||
"""
|
"""
|
||||||
text(t::PlotText) = t
|
text(t::PlotText) = t
|
||||||
text(t::PlotText, font::Font) = PlotText(t.str, font)
|
text(t::PlotText, font::Font) = PlotText(t.str, font)
|
||||||
@ -779,7 +779,7 @@ end
|
|||||||
|
|
||||||
# -----------------------------------------------------------------------
|
# -----------------------------------------------------------------------
|
||||||
"create a BezierCurve for plotting"
|
"create a BezierCurve for plotting"
|
||||||
mutable struct BezierCurve{T <: StaticArrays.SVector}
|
mutable struct BezierCurve{T <: GeometryTypes.Point}
|
||||||
control_points::Vector{T}
|
control_points::Vector{T}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -792,9 +792,6 @@ function (bc::BezierCurve)(t::Real)
|
|||||||
p
|
p
|
||||||
end
|
end
|
||||||
|
|
||||||
# mean(x::Real, y::Real) = 0.5*(x+y) #commented out as I cannot see this used anywhere and it overwrites a Base method with different functionality
|
|
||||||
# mean{N,T<:Real}(ps::StaticArrays.SVector{N,T}...) = sum(ps) / length(ps) # I also could not see this used anywhere, and it's type piracy - implementing a NaNMath version for this would just involve converting to a standard array
|
|
||||||
|
|
||||||
@deprecate curve_points coords
|
@deprecate curve_points coords
|
||||||
|
|
||||||
coords(curve::BezierCurve, n::Integer = 30; range = [0,1]) = map(curve, range(range..., stop=n, length=50))
|
coords(curve::BezierCurve, n::Integer = 30; range = [0,1]) = map(curve, range(range..., stop=n, length=50))
|
||||||
|
|||||||
@ -554,7 +554,7 @@ end
|
|||||||
#
|
#
|
||||||
#
|
#
|
||||||
# # --------------------------------------------------------------------
|
# # --------------------------------------------------------------------
|
||||||
# # Lists of tuples and StaticArrays
|
# # Lists of tuples and GeometryTypes.Points
|
||||||
# # --------------------------------------------------------------------
|
# # --------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# # if we get an unhandled tuple, just splat it in
|
# # if we get an unhandled tuple, just splat it in
|
||||||
@ -576,14 +576,14 @@ end
|
|||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# # 2D StaticArrays
|
# # 2D Points
|
||||||
@recipe f(xy::AVec{StaticArrays.SVector{2,T}}) where {T<:Number} = unzip(xy)
|
@recipe f(xy::AVec{GeometryTypes.Point{2,T}}) where {T<:Number} = unzip(xy)
|
||||||
@recipe f(xy::StaticArrays.SVector{2,T}) where {T<:Number} = [xy[1]], [xy[2]]
|
@recipe f(xy::GeometryTypes.Point{2,T}) where {T<:Number} = [xy[1]], [xy[2]]
|
||||||
|
|
||||||
#
|
#
|
||||||
# # 3D StaticArrays
|
# # 3D Points
|
||||||
@recipe f(xyz::AVec{StaticArrays.SVector{3,T}}) where {T<:Number} = unzip(xyz)
|
@recipe f(xyz::AVec{GeometryTypes.Point{3,T}}) where {T<:Number} = unzip(xyz)
|
||||||
@recipe f(xyz::StaticArrays.SVector{3,T}) where {T<:Number} = [xyz[1]], [xyz[2]], [xyz[3]]
|
@recipe f(xyz::GeometryTypes.Point{3,T}) where {T<:Number} = [xyz[1]], [xyz[2]], [xyz[3]]
|
||||||
|
|
||||||
#
|
#
|
||||||
# # --------------------------------------------------------------------
|
# # --------------------------------------------------------------------
|
||||||
|
|||||||
22
src/utils.jl
22
src/utils.jl
@ -290,14 +290,14 @@ unzip(xy::AVec{Tuple{X,Y}}) where {X,Y} = [t[1] for t in xy], [t[2]
|
|||||||
unzip(xyz::AVec{Tuple{X,Y,Z}}) where {X,Y,Z} = [t[1] for t in xyz], [t[2] for t in xyz], [t[3] for t in xyz]
|
unzip(xyz::AVec{Tuple{X,Y,Z}}) where {X,Y,Z} = [t[1] for t in xyz], [t[2] for t in xyz], [t[3] for t in xyz]
|
||||||
unzip(xyuv::AVec{Tuple{X,Y,U,V}}) where {X,Y,U,V} = [t[1] for t in xyuv], [t[2] for t in xyuv], [t[3] for t in xyuv], [t[4] for t in xyuv]
|
unzip(xyuv::AVec{Tuple{X,Y,U,V}}) where {X,Y,U,V} = [t[1] for t in xyuv], [t[2] for t in xyuv], [t[3] for t in xyuv], [t[4] for t in xyuv]
|
||||||
|
|
||||||
unzip(xy::AVec{StaticArrays.SVector{2,T}}) where {T} = T[t[1] for t in xy], T[t[2] for t in xy]
|
unzip(xy::AVec{GeometryTypes.Point{2,T}}) where {T} = T[t[1] for t in xy], T[t[2] for t in xy]
|
||||||
unzip(xy::StaticArrays.SVector{2,T}) where {T} = T[xy[1]], T[xy[2]]
|
unzip(xy::GeometryTypes.Point{2,T}) where {T} = T[xy[1]], T[xy[2]]
|
||||||
|
|
||||||
unzip(xyz::AVec{StaticArrays.SVector{3,T}}) where {T} = T[t[1] for t in xyz], T[t[2] for t in xyz], T[t[3] for t in xyz]
|
unzip(xyz::AVec{GeometryTypes.Point{3,T}}) where {T} = T[t[1] for t in xyz], T[t[2] for t in xyz], T[t[3] for t in xyz]
|
||||||
unzip(xyz::StaticArrays.SVector{3,T}) where {T} = T[xyz[1]], T[xyz[2]], T[xyz[3]]
|
unzip(xyz::GeometryTypes.Point{3,T}) where {T} = T[xyz[1]], T[xyz[2]], T[xyz[3]]
|
||||||
|
|
||||||
unzip(xyuv::AVec{StaticArrays.SVector{4,T}}) where {T} = T[t[1] for t in xyuv], T[t[2] for t in xyuv], T[t[3] for t in xyuv], T[t[4] for t in xyuv]
|
unzip(xyuv::AVec{GeometryTypes.Point{4,T}}) where {T} = T[t[1] for t in xyuv], T[t[2] for t in xyuv], T[t[3] for t in xyuv], T[t[4] for t in xyuv]
|
||||||
unzip(xyuv::StaticArrays.SVector{4,T}) where {T} = T[xyuv[1]], T[xyuv[2]], T[xyuv[3]], T[xyuv[4]]
|
unzip(xyuv::GeometryTypes.Point{4,T}) where {T} = T[xyuv[1]], T[xyuv[2]], T[xyuv[3]], T[xyuv[4]]
|
||||||
|
|
||||||
# given 2-element lims and a vector of data x, widen lims to account for the extrema of x
|
# given 2-element lims and a vector of data x, widen lims to account for the extrema of x
|
||||||
function _expand_limits(lims, x)
|
function _expand_limits(lims, x)
|
||||||
@ -592,15 +592,15 @@ function colorbar_style(series::Series)
|
|||||||
@warn "Non-boolean colorbar_entry ignored."
|
@warn "Non-boolean colorbar_entry ignored."
|
||||||
colorbar_entry = true
|
colorbar_entry = true
|
||||||
end
|
end
|
||||||
|
|
||||||
if !colorbar_entry
|
if !colorbar_entry
|
||||||
nothing
|
nothing
|
||||||
elseif isfilledcontour(series)
|
elseif isfilledcontour(series)
|
||||||
cbar_fill
|
cbar_fill
|
||||||
elseif iscontour(series)
|
elseif iscontour(series)
|
||||||
cbar_lines
|
cbar_lines
|
||||||
elseif series[:seriestype] ∈ (:heatmap,:surface) ||
|
elseif series[:seriestype] ∈ (:heatmap,:surface) ||
|
||||||
any(series[z] !== nothing for z ∈ [:marker_z,:line_z,:fill_z])
|
any(series[z] !== nothing for z ∈ [:marker_z,:line_z,:fill_z])
|
||||||
cbar_gradient
|
cbar_gradient
|
||||||
else
|
else
|
||||||
nothing
|
nothing
|
||||||
@ -626,7 +626,7 @@ function contour_levels(series::Series, clims)
|
|||||||
levels
|
levels
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for comp in (:line, :fill, :marker)
|
for comp in (:line, :fill, :marker)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user