Merge pull request #2186 from JuliaPlots/as/fix-ribbon-2tuple-dispatch

Fix plotting ribbons as 2-tuples
This commit is contained in:
Daniel Schwabeneder 2019-10-13 19:23:12 +02:00 committed by GitHub
commit a76e756f4f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 2 deletions

View File

@ -165,7 +165,7 @@ PlotExample("Marker types",
), ),
PlotExample("Bar", PlotExample("Bar",
"x is the midpoint of the bar. (todo: allow passing of edges instead of midpoints)", "`x` is the midpoint of the bar. (todo: allow passing of edges instead of midpoints)",
[:(begin [:(begin
bar(randn(99)) bar(randn(99))
end)] end)]
@ -454,6 +454,23 @@ see: http://stackoverflow.com/a/37732384/5075246
end)] end)]
), ),
PlotExample("Ribbons",
"""
Ribbons can be added to lines via the `ribbon` keyword;
you can pass a tuple of arrays (upper and lower bounds),
a single Array (for symmetric ribbons), a Function, or a number.
""",
[:(begin
plot(
plot(0:10; ribbon = (LinRange(0, 2, 10), LinRange(0, 1, 10))),
plot(0:10; ribbon = 0:0.5:5),
plot(0:10; ribbon = sqrt),
plot(0:10; ribbon = 1),
)
end)
]
),
] ]
# Some constants for PlotDocs and PlotReferenceImages # Some constants for PlotDocs and PlotReferenceImages

View File

@ -61,7 +61,7 @@ process_fillrange(range, plotattributes) = convertToAnyVector(range, plotattribu
process_ribbon(ribbon::Number, plotattributes) = [ribbon] process_ribbon(ribbon::Number, plotattributes) = [ribbon]
process_ribbon(ribbon, plotattributes) = convertToAnyVector(ribbon, plotattributes) process_ribbon(ribbon, plotattributes) = convertToAnyVector(ribbon, plotattributes)
# ribbon as a tuple: (lower_ribbons, upper_ribbons) # ribbon as a tuple: (lower_ribbons, upper_ribbons)
process_ribbon(ribbon::Tuple{Any,Any}) = collect(zip(convertToAnyVector(ribbon[1], plotattributes), process_ribbon(ribbon::Tuple{Any,Any}, plotattributes) = collect(zip(convertToAnyVector(ribbon[1], plotattributes),
convertToAnyVector(ribbon[2], plotattributes))) convertToAnyVector(ribbon[2], plotattributes)))