Merge remote-tracking branch 'upstream/master'
t push
This commit is contained in:
commit
065ff48b15
@ -45,7 +45,7 @@ notifications:
|
|||||||
# uncomment the following lines to override the default test script
|
# uncomment the following lines to override the default test script
|
||||||
script:
|
script:
|
||||||
- if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
|
- if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
|
||||||
- julia -e 'using Pkg; Pkg.add(pwd()); Pkg.build("Plots")'
|
- julia -e 'import Pkg; Pkg.add(Pkg.PackageSpec(path=pwd())); Pkg.build("Plots")'
|
||||||
- julia test/travis_commands.jl
|
- julia test/travis_commands.jl
|
||||||
# - julia -e 'Pkg.clone("ImageMagick"); Pkg.build("ImageMagick")'
|
# - julia -e 'Pkg.clone("ImageMagick"); Pkg.build("ImageMagick")'
|
||||||
# - julia -e 'Pkg.clone("GR"); Pkg.build("GR")'
|
# - julia -e 'Pkg.clone("GR"); Pkg.build("GR")'
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
[](https://travis-ci.org/JuliaPlots/Plots.jl)
|
[](https://travis-ci.org/JuliaPlots/Plots.jl)
|
||||||
[](https://ci.appveyor.com/project/mkborregaard/plots-jl)
|
[](https://ci.appveyor.com/project/mkborregaard/plots-jl)
|
||||||
[](https://gitter.im/tbreloff/Plots.jl?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
[](https://gitter.im/tbreloff/Plots.jl?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||||
|
<a href="http://docs.juliaplots.org/latest/" target="_blank"><img src="https://img.shields.io/badge/docs-latest-blue.svg" alt="Latest documentation"></a>
|
||||||
<!-- [](http://pkg.julialang.org/?pkg=Plots&ver=0.3) -->
|
<!-- [](http://pkg.julialang.org/?pkg=Plots&ver=0.3) -->
|
||||||
<!-- [](http://pkg.julialang.org/?pkg=Plots&ver=0.4) -->
|
<!-- [](http://pkg.julialang.org/?pkg=Plots&ver=0.4) -->
|
||||||
<!-- [](https://coveralls.io/r/tbreloff/Plots.jl?branch=master) -->
|
<!-- [](https://coveralls.io/r/tbreloff/Plots.jl?branch=master) -->
|
||||||
@ -21,5 +22,3 @@ Plots is a plotting API and toolset. My goals with the package are:
|
|||||||
- **Consistent**. Don't commit to one graphics package, use the same code everywhere.
|
- **Consistent**. Don't commit to one graphics package, use the same code everywhere.
|
||||||
- **Lightweight**. Very few dependencies.
|
- **Lightweight**. Very few dependencies.
|
||||||
- **Smart**. Attempts to figure out what you **want** it to do... not just what you **tell** it.
|
- **Smart**. Attempts to figure out what you **want** it to do... not just what you **tell** it.
|
||||||
|
|
||||||
View the [full documentation](http://docs.juliaplots.org/latest).
|
|
||||||
|
|||||||
@ -104,8 +104,6 @@ export
|
|||||||
rotate,
|
rotate,
|
||||||
rotate!,
|
rotate!,
|
||||||
center,
|
center,
|
||||||
P2,
|
|
||||||
P3,
|
|
||||||
BezierCurve,
|
BezierCurve,
|
||||||
|
|
||||||
plotattr
|
plotattr
|
||||||
|
|||||||
@ -27,8 +27,8 @@ const _arg_desc = KW(
|
|||||||
:x => "Various. Input data. First Dimension",
|
:x => "Various. Input data. First Dimension",
|
||||||
:y => "Various. Input data. Second Dimension",
|
:y => "Various. Input data. Second Dimension",
|
||||||
:z => "Various. Input data. Third Dimension. May be wrapped by a `Surface` for surface and heatmap types.",
|
:z => "Various. Input data. Third Dimension. May be wrapped by a `Surface` for surface and heatmap types.",
|
||||||
:marker_z => "AbstractVector, Function `f(x,y,z) -> z_value`, or nothing. z-values for each series data point, which correspond to the color to be used from a markercolor gradient.",
|
:marker_z => "AbstractVector, Function `f(x,y,z) -> z_value`, or Function `f(x,y) -> z_value`, or nothing. z-values for each series data point, which correspond to the color to be used from a markercolor gradient.",
|
||||||
:line_z => "AbstractVector, Function `f(x,y,z) -> z_value`, or nothing. z-values for each series line segment, which correspond to the color to be used from a linecolor gradient. Note that for N points, only the first N-1 values are used (one per line-segment).",
|
:line_z => "AbstractVector, Function `f(x,y,z) -> z_value`, or Function `f(x,y) -> z_value`, or nothing. z-values for each series line segment, which correspond to the color to be used from a linecolor gradient. Note that for N points, only the first N-1 values are used (one per line-segment).",
|
||||||
:fill_z => "Matrix{Float64} of the same size as z matrix, which specifies the color of the 3D surface; the default value is `nothing`.",
|
:fill_z => "Matrix{Float64} of the same size as z matrix, which specifies the color of the 3D surface; the default value is `nothing`.",
|
||||||
:levels => "Integer, NTuple{2,Integer}. Number of levels (or x-levels/y-levels) for a contour type.",
|
:levels => "Integer, NTuple{2,Integer}. Number of levels (or x-levels/y-levels) for a contour type.",
|
||||||
:orientation => "Symbol. Horizontal or vertical orientation for bar types. Values `:h`, `:hor`, `:horizontal` correspond to horizontal (sideways, anchored to y-axis), and `:v`, `:vert`, and `:vertical` correspond to vertical (the default).",
|
:orientation => "Symbol. Horizontal or vertical orientation for bar types. Values `:h`, `:hor`, `:horizontal` correspond to horizontal (sideways, anchored to y-axis), and `:v`, `:vert`, and `:vertical` correspond to vertical (the default).",
|
||||||
|
|||||||
24
src/args.jl
24
src/args.jl
@ -1086,17 +1086,14 @@ function extractGroupArgs(vs::Tuple, args...)
|
|||||||
end
|
end
|
||||||
|
|
||||||
# allow passing NamedTuples for a named legend entry
|
# allow passing NamedTuples for a named legend entry
|
||||||
@require NamedTuples = "73a701b4-84e1-5df0-88ff-1968ee2ee8dc" begin
|
legendEntryFromTuple(ns::NamedTuple) =
|
||||||
legendEntryFromTuple(ns::NamedTuples.NamedTuple) =
|
join(["$k = $v" for (k, v) in pairs(ns)], ", ")
|
||||||
join(["$k = $v" for (k, v) in zip(keys(ns), values(ns))], ", ")
|
|
||||||
|
|
||||||
function extractGroupArgs(vs::NamedTuples.NamedTuple, args...)
|
function extractGroupArgs(vs::NamedTuple, args...)
|
||||||
isempty(vs) && return GroupBy([""], [1:size(args[1],1)])
|
isempty(vs) && return GroupBy([""], [1:size(args[1],1)])
|
||||||
NT = eval(:(NamedTuples.@NT($(keys(vs)...)))){map(eltype, vs)...}
|
v = map(NamedTuple{keys(vs)}∘tuple, values(vs)...)
|
||||||
v = map(NT, vs...)
|
|
||||||
extractGroupArgs(v, args...; legendEntry = legendEntryFromTuple)
|
extractGroupArgs(v, args...; legendEntry = legendEntryFromTuple)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
# expecting a mapping of "group label" to "group indices"
|
# expecting a mapping of "group label" to "group indices"
|
||||||
function extractGroupArgs(idxmap::Dict{T,V}, args...) where {T, V<:AVec{Int}}
|
function extractGroupArgs(idxmap::Dict{T,V}, args...) where {T, V<:AVec{Int}}
|
||||||
@ -1521,6 +1518,11 @@ function getSeriesRGBColor(c, sp::Subplot, n::Int)
|
|||||||
plot_color(c)
|
plot_color(c)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function getSeriesRGBColor(c::AbstractArray, sp::Subplot, n::Int)
|
||||||
|
@info "it is surprising that this function is called - please report a use case as a Plots issue"
|
||||||
|
map(x->getSeriesRGBColor(x, sp, n), c)
|
||||||
|
end
|
||||||
|
|
||||||
function ensure_gradient!(d::KW, csym::Symbol, asym::Symbol)
|
function ensure_gradient!(d::KW, csym::Symbol, asym::Symbol)
|
||||||
if !isa(d[csym], ColorGradient)
|
if !isa(d[csym], ColorGradient)
|
||||||
d[csym] = typeof(d[asym]) <: AbstractVector ? cgrad() : cgrad(alpha = d[asym])
|
d[csym] = typeof(d[asym]) <: AbstractVector ? cgrad() : cgrad(alpha = d[asym])
|
||||||
@ -1563,7 +1565,7 @@ function _update_series_attributes!(d::KW, plt::Plot, sp::Subplot)
|
|||||||
end
|
end
|
||||||
|
|
||||||
# update series color
|
# update series color
|
||||||
d[:seriescolor] = getSeriesRGBColor.(d[:seriescolor], Ref(sp), plotIndex)
|
d[:seriescolor] = getSeriesRGBColor(d[:seriescolor], sp, plotIndex)
|
||||||
|
|
||||||
# update other colors
|
# update other colors
|
||||||
for s in (:line, :marker, :fill)
|
for s in (:line, :marker, :fill)
|
||||||
@ -1577,7 +1579,7 @@ function _update_series_attributes!(d::KW, plt::Plot, sp::Subplot)
|
|||||||
elseif d[csym] == :match
|
elseif d[csym] == :match
|
||||||
plot_color(d[:seriescolor])
|
plot_color(d[:seriescolor])
|
||||||
else
|
else
|
||||||
getSeriesRGBColor.(d[csym], Ref(sp), plotIndex)
|
getSeriesRGBColor(d[csym], sp, plotIndex)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1585,9 +1587,9 @@ function _update_series_attributes!(d::KW, plt::Plot, sp::Subplot)
|
|||||||
d[:markerstrokecolor] = if d[:markerstrokecolor] == :match
|
d[:markerstrokecolor] = if d[:markerstrokecolor] == :match
|
||||||
plot_color(sp[:foreground_color_subplot])
|
plot_color(sp[:foreground_color_subplot])
|
||||||
elseif d[:markerstrokecolor] == :auto
|
elseif d[:markerstrokecolor] == :auto
|
||||||
getSeriesRGBColor.(d[:markercolor], Ref(sp), plotIndex)
|
getSeriesRGBColor(d[:markercolor], sp, plotIndex)
|
||||||
else
|
else
|
||||||
getSeriesRGBColor.(d[:markerstrokecolor], Ref(sp), plotIndex)
|
getSeriesRGBColor(d[:markerstrokecolor], sp, plotIndex)
|
||||||
end
|
end
|
||||||
|
|
||||||
# if marker_z, fill_z or line_z are set, ensure we have a gradient
|
# if marker_z, fill_z or line_z are set, ensure we have a gradient
|
||||||
|
|||||||
@ -387,7 +387,7 @@ end
|
|||||||
function _initialize_backend(::PyPlotBackend)
|
function _initialize_backend(::PyPlotBackend)
|
||||||
@eval Main begin
|
@eval Main begin
|
||||||
import PyPlot, PyCall
|
import PyPlot, PyCall
|
||||||
import LaTeXStrings: latexstring
|
import LaTeXStrings
|
||||||
|
|
||||||
export PyPlot
|
export PyPlot
|
||||||
|
|
||||||
|
|||||||
@ -27,7 +27,7 @@ const _gr_attr = merge_with_base_supported([
|
|||||||
:guidefontfamily, :guidefontsize, :guidefonthalign, :guidefontvalign,
|
:guidefontfamily, :guidefontsize, :guidefonthalign, :guidefontvalign,
|
||||||
:guidefontrotation, :guidefontcolor,
|
:guidefontrotation, :guidefontcolor,
|
||||||
:grid, :gridalpha, :gridstyle, :gridlinewidth,
|
:grid, :gridalpha, :gridstyle, :gridlinewidth,
|
||||||
:legend, :legendtitle, :colorbar,
|
:legend, :legendtitle, :colorbar, :colorbar_title,
|
||||||
:fill_z, :line_z, :marker_z, :levels,
|
:fill_z, :line_z, :marker_z, :levels,
|
||||||
:ribbon, :quiver,
|
:ribbon, :quiver,
|
||||||
:orientation,
|
:orientation,
|
||||||
@ -421,6 +421,8 @@ const viewport_plotarea = zeros(4)
|
|||||||
# the size of the current plot in pixels
|
# the size of the current plot in pixels
|
||||||
const gr_plot_size = [600.0, 400.0]
|
const gr_plot_size = [600.0, 400.0]
|
||||||
|
|
||||||
|
const gr_colorbar_ratio = 0.1
|
||||||
|
|
||||||
function gr_viewport_from_bbox(sp::Subplot{GRBackend}, bb::BoundingBox, w, h, viewport_canvas)
|
function gr_viewport_from_bbox(sp::Subplot{GRBackend}, bb::BoundingBox, w, h, viewport_canvas)
|
||||||
viewport = zeros(4)
|
viewport = zeros(4)
|
||||||
viewport[1] = viewport_canvas[2] * (left(bb) / w)
|
viewport[1] = viewport_canvas[2] * (left(bb) / w)
|
||||||
@ -436,7 +438,7 @@ function gr_viewport_from_bbox(sp::Subplot{GRBackend}, bb::BoundingBox, w, h, vi
|
|||||||
viewport[4] = 0.5 * (vp[3] + vp[4] + extent)
|
viewport[4] = 0.5 * (vp[3] + vp[4] + extent)
|
||||||
end
|
end
|
||||||
if hascolorbar(sp)
|
if hascolorbar(sp)
|
||||||
viewport[2] -= 0.1
|
viewport[2] -= gr_colorbar_ratio
|
||||||
end
|
end
|
||||||
viewport
|
viewport
|
||||||
end
|
end
|
||||||
@ -483,6 +485,13 @@ function gr_colorbar(sp::Subplot, clims)
|
|||||||
GR.cellarray(xmin, xmax, clims[2], clims[1], 1, length(l), l)
|
GR.cellarray(xmin, xmax, clims[2], clims[1], 1, length(l), l)
|
||||||
ztick = 0.5 * GR.tick(clims[1], clims[2])
|
ztick = 0.5 * GR.tick(clims[1], clims[2])
|
||||||
GR.axes(0, ztick, xmax, clims[1], 0, 1, 0.005)
|
GR.axes(0, ztick, xmax, clims[1], 0, 1, 0.005)
|
||||||
|
|
||||||
|
gr_set_font(guidefont(sp[:yaxis]))
|
||||||
|
GR.settextalign(GR.TEXT_HALIGN_CENTER, GR.TEXT_VALIGN_TOP)
|
||||||
|
GR.setcharup(-1, 0)
|
||||||
|
gr_text(viewport_plotarea[2] + gr_colorbar_ratio,
|
||||||
|
gr_view_ycenter(), sp[:colorbar_title])
|
||||||
|
|
||||||
gr_set_viewport_plotarea()
|
gr_set_viewport_plotarea()
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -657,6 +666,9 @@ function _update_min_padding!(sp::Subplot{GRBackend})
|
|||||||
if sp[:yaxis][:guide] != ""
|
if sp[:yaxis][:guide] != ""
|
||||||
leftpad += 4mm
|
leftpad += 4mm
|
||||||
end
|
end
|
||||||
|
if sp[:colorbar_title] != ""
|
||||||
|
rightpad += 4mm
|
||||||
|
end
|
||||||
sp.minpad = Tuple(dpi * [leftpad, toppad, rightpad, bottompad])
|
sp.minpad = Tuple(dpi * [leftpad, toppad, rightpad, bottompad])
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1103,10 +1115,10 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
GR.setspace(zmin, zmax, 0, 90)
|
GR.setspace(zmin, zmax, 0, 90)
|
||||||
grad = isa(series[:fillcolor], ColorGradient) ? series[:fillcolor] : cgrad()
|
grad = isa(series[:fillcolor], ColorGradient) ? series[:fillcolor] : cgrad()
|
||||||
colors = [plot_color(grad[clamp((zi-zmin) / (zmax-zmin), 0, 1)], series[:fillalpha]) for zi=z]
|
colors = [plot_color(grad[clamp((zi-zmin) / (zmax-zmin), 0, 1)], series[:fillalpha]) for zi=z]
|
||||||
rgba = map(c -> UInt32( round(Int, alpha(c) * 255) << 24 +
|
rgba = map(c -> UInt32( round(UInt, alpha(c) * 255) << 24 +
|
||||||
round(Int, blue(c) * 255) << 16 +
|
round(UInt, blue(c) * 255) << 16 +
|
||||||
round(Int, green(c) * 255) << 8 +
|
round(UInt, green(c) * 255) << 8 +
|
||||||
round(Int, red(c) * 255) ), colors)
|
round(UInt, red(c) * 255) ), colors)
|
||||||
w, h = length(x), length(y)
|
w, h = length(x), length(y)
|
||||||
GR.drawimage(xmin, xmax, ymax, ymin, w, h, rgba)
|
GR.drawimage(xmin, xmax, ymax, ymin, w, h, rgba)
|
||||||
|
|
||||||
@ -1210,12 +1222,12 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
xmin, xmax = ignorenan_extrema(series[:x]); ymin, ymax = ignorenan_extrema(series[:y])
|
xmin, xmax = ignorenan_extrema(series[:x]); ymin, ymax = ignorenan_extrema(series[:y])
|
||||||
if eltype(z) <: Colors.AbstractGray
|
if eltype(z) <: Colors.AbstractGray
|
||||||
grey = round.(UInt8, float(z) * 255)
|
grey = round.(UInt8, float(z) * 255)
|
||||||
rgba = map(c -> UInt32( 0xff000000 + Int(c)<<16 + Int(c)<<8 + Int(c) ), grey)
|
rgba = map(c -> UInt32( 0xff000000 + UInt(c)<<16 + UInt(c)<<8 + UInt(c) ), grey)
|
||||||
else
|
else
|
||||||
rgba = map(c -> UInt32( round(Int, alpha(c) * 255) << 24 +
|
rgba = map(c -> UInt32( round(UInt, alpha(c) * 255) << 24 +
|
||||||
round(Int, blue(c) * 255) << 16 +
|
round(UInt, blue(c) * 255) << 16 +
|
||||||
round(Int, green(c) * 255) << 8 +
|
round(UInt, green(c) * 255) << 8 +
|
||||||
round(Int, red(c) * 255) ), z)
|
round(UInt, red(c) * 255) ), z)
|
||||||
end
|
end
|
||||||
GR.drawimage(xmin, xmax, ymax, ymin, w, h, rgba)
|
GR.drawimage(xmin, xmax, ymax, ymin, w, h, rgba)
|
||||||
end
|
end
|
||||||
@ -1227,16 +1239,18 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
gr_text(GR.wctondc(xi, yi)..., str)
|
gr_text(GR.wctondc(xi, yi)..., str)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
GR.restorestate()
|
||||||
|
end
|
||||||
|
|
||||||
# draw the colorbar
|
# draw the colorbar
|
||||||
if cmap && st != :contour # special colorbar with steps is drawn for contours
|
GR.savestate()
|
||||||
|
# special colorbar with steps is drawn for contours
|
||||||
|
if cmap && any(series[:seriestype] != :contour for series in series_list(sp))
|
||||||
gr_set_line(1, :solid, yaxis[:foreground_color_axis])
|
gr_set_line(1, :solid, yaxis[:foreground_color_axis])
|
||||||
gr_set_transparency(1)
|
gr_set_transparency(1)
|
||||||
gr_colorbar(sp, clims)
|
gr_colorbar(sp, clims)
|
||||||
end
|
end
|
||||||
|
|
||||||
GR.restorestate()
|
GR.restorestate()
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
# add the legend
|
# add the legend
|
||||||
if sp[:legend] != :none
|
if sp[:legend] != :none
|
||||||
|
|||||||
@ -23,7 +23,7 @@ const _pgfplots_attr = merge_with_base_supported([
|
|||||||
:guide, :lims, :ticks, :scale, :flip, :rotation,
|
:guide, :lims, :ticks, :scale, :flip, :rotation,
|
||||||
:tickfont, :guidefont, :legendfont,
|
:tickfont, :guidefont, :legendfont,
|
||||||
:grid, :legend,
|
:grid, :legend,
|
||||||
:colorbar,
|
:colorbar, :colorbar_title,
|
||||||
:fill_z, :line_z, :marker_z, :levels,
|
:fill_z, :line_z, :marker_z, :levels,
|
||||||
# :ribbon, :quiver, :arrow,
|
# :ribbon, :quiver, :arrow,
|
||||||
# :orientation,
|
# :orientation,
|
||||||
@ -550,6 +550,7 @@ function _update_plot_object(plt::Plot{PGFPlotsBackend})
|
|||||||
end
|
end
|
||||||
@label colorbar_end
|
@label colorbar_end
|
||||||
|
|
||||||
|
push!(style, "colorbar style={title=$(sp[:colorbar_title])}")
|
||||||
o = axisf(; style = join(style, ","), kw...)
|
o = axisf(; style = join(style, ","), kw...)
|
||||||
|
|
||||||
# add the series object to the PGFPlots.Axis
|
# add the series object to the PGFPlots.Axis
|
||||||
|
|||||||
@ -236,18 +236,19 @@ function add_pyfixedformatter(cbar, vals::AVec)
|
|||||||
cbar[:update_ticks]()
|
cbar[:update_ticks]()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@require LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f" begin
|
||||||
function labelfunc(scale::Symbol, backend::PyPlotBackend)
|
function labelfunc(scale::Symbol, backend::PyPlotBackend)
|
||||||
if scale == :log10
|
if scale == :log10
|
||||||
x -> latexstring("10^{$x}")
|
x -> LaTeXStrings.latexstring("10^{$x}")
|
||||||
elseif scale == :log2
|
elseif scale == :log2
|
||||||
x -> latexstring("2^{$x}")
|
x -> LaTeXStrings.latexstring("2^{$x}")
|
||||||
elseif scale == :ln
|
elseif scale == :ln
|
||||||
x -> latexstring("e^{$x}")
|
x -> LaTeXStrings.latexstring("e^{$x}")
|
||||||
else
|
else
|
||||||
string
|
string
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
@require PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0" begin
|
@require PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0" begin
|
||||||
function py_mask_nans(z)
|
function py_mask_nans(z)
|
||||||
|
|||||||
@ -427,7 +427,7 @@ each line segment or marker in the plot.
|
|||||||
x = t .* cos.(θ)
|
x = t .* cos.(θ)
|
||||||
y = t .* sin.(θ)
|
y = t .* sin.(θ)
|
||||||
p1 = plot(x, y, line_z=t, linewidth=3, legend=false)
|
p1 = plot(x, y, line_z=t, linewidth=3, legend=false)
|
||||||
p2 = scatter(x, y, marker_z=t, color=:bluesreds, legend=false)
|
p2 = scatter(x, y, marker_z=(x,y)->x+y, color=:bluesreds, legend=false)
|
||||||
plot(p1, p2)
|
plot(p1, p2)
|
||||||
end)]
|
end)]
|
||||||
),
|
),
|
||||||
|
|||||||
@ -117,12 +117,12 @@ function _preprocess_userrecipe(kw::KW)
|
|||||||
# map marker_z if it's a Function
|
# map marker_z if it's a Function
|
||||||
if isa(get(kw, :marker_z, nothing), Function)
|
if isa(get(kw, :marker_z, nothing), Function)
|
||||||
# TODO: should this take y and/or z as arguments?
|
# TODO: should this take y and/or z as arguments?
|
||||||
kw[:marker_z] = map(kw[:marker_z], kw[:x], kw[:y], kw[:z])
|
kw[:marker_z] = isa(kw[:z], Nothing) ? map(kw[:marker_z], kw[:x], kw[:y]) : map(kw[:marker_z], kw[:x], kw[:y], kw[:z])
|
||||||
end
|
end
|
||||||
|
|
||||||
# map line_z if it's a Function
|
# map line_z if it's a Function
|
||||||
if isa(get(kw, :line_z, nothing), Function)
|
if isa(get(kw, :line_z, nothing), Function)
|
||||||
kw[:line_z] = map(kw[:line_z], kw[:x], kw[:y], kw[:z])
|
kw[:line_z] = isa(kw[:z], Nothing) ? map(kw[:line_z], kw[:x], kw[:y]) : map(kw[:line_z], kw[:x], kw[:y], kw[:z])
|
||||||
end
|
end
|
||||||
|
|
||||||
# convert a ribbon into a fillrange
|
# convert a ribbon into a fillrange
|
||||||
|
|||||||
@ -40,6 +40,9 @@ function plotattr(attribute::AbstractString)
|
|||||||
error("There is no attribute named $attribute")
|
error("There is no attribute named $attribute")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
printnothing(x) = x
|
||||||
|
printnothing(x::Nothing) = "nothing"
|
||||||
|
|
||||||
function plotattr(attrtype::Symbol, attribute::AbstractString)
|
function plotattr(attrtype::Symbol, attribute::AbstractString)
|
||||||
in(attrtype, keys(_attribute_defaults)) || ArgumentError("`attrtype` must match one of $(attrtypes())")
|
in(attrtype, keys(_attribute_defaults)) || ArgumentError("`attrtype` must match one of $(attrtypes())")
|
||||||
|
|
||||||
@ -49,14 +52,14 @@ function plotattr(attrtype::Symbol, attribute::AbstractString)
|
|||||||
first_period_idx = findfirst(isequal('.'), desc)
|
first_period_idx = findfirst(isequal('.'), desc)
|
||||||
typedesc = desc[1:first_period_idx-1]
|
typedesc = desc[1:first_period_idx-1]
|
||||||
desc = strip(desc[first_period_idx+1:end])
|
desc = strip(desc[first_period_idx+1:end])
|
||||||
als = keys(filter((_,v)->v==attribute, _keyAliases)) |> collect |> sort
|
als = keys(filter(x->x[2]==attribute, _keyAliases)) |> collect |> sort
|
||||||
als = join(map(string,als), ", ")
|
als = join(map(string,als), ", ")
|
||||||
def = _attribute_defaults[attrtype][attribute]
|
def = _attribute_defaults[attrtype][attribute]
|
||||||
|
|
||||||
|
|
||||||
# Looks up the different elements and plots them
|
# Looks up the different elements and plots them
|
||||||
println("$attribute ", typedesc == "" ? "" : "{$typedesc}", "\n",
|
println("$(printnothing(attribute)) ", typedesc == "" ? "" : "{$(printnothing(typedesc))}", "\n",
|
||||||
als == "" ? "" : "$als\n",
|
als == "" ? "" : "$(printnothing(als))\n",
|
||||||
"\n$desc\n",
|
"\n$(printnothing(desc))\n",
|
||||||
"$(attrtype) attribute, ", def == "" ? "" : " default: $def")
|
"$(printnothing(attrtype)) attribute, ", def == "" ? "" : " default: $(printnothing(def))")
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user