Revert "Transfer portfoliocomposition recipe from PlotRecipes"
This commit is contained in:
parent
6940f5a982
commit
6741287ef1
@ -435,24 +435,6 @@ each line segment or marker in the plot.
|
||||
end)]
|
||||
),
|
||||
|
||||
PlotExample("Portfolio Composition maps",
|
||||
"""
|
||||
see: http://stackoverflow.com/a/37732384/5075246
|
||||
""",
|
||||
[:(begin
|
||||
using Random
|
||||
Random.seed!(111)
|
||||
tickers = ["IBM", "Google", "Apple", "Intel"]
|
||||
N = 10
|
||||
D = length(tickers)
|
||||
weights = rand(N,D)
|
||||
weights ./= sum(weights, dims = 2)
|
||||
returns = sort!((1:N) + D*randn(N))
|
||||
|
||||
portfoliocomposition(weights, returns, labels = permutedims(tickers))
|
||||
end)]
|
||||
),
|
||||
|
||||
]
|
||||
|
||||
# Some constants for PlotDocs and PlotReferenceImages
|
||||
@ -464,8 +446,6 @@ _backend_skips = Dict(
|
||||
:pgfplots => [2, 5, 6, 10, 16, 20, 22, 23, 25, 28, 30],
|
||||
)
|
||||
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------------
|
||||
|
||||
# make and display one plot
|
||||
|
||||
@ -1131,25 +1131,3 @@ end
|
||||
title := string(grad.args[1])
|
||||
z
|
||||
end
|
||||
|
||||
|
||||
# Moved in from PlotRecipes - see: http://stackoverflow.com/a/37732384/5075246
|
||||
@userplot PortfolioComposition
|
||||
|
||||
# this shows the shifting composition of a basket of something over a variable
|
||||
# - "returns" are the dependent variable
|
||||
# - "weights" are a matrix where the ith column is the composition for returns[i]
|
||||
# - since each polygon is its own series, you can assign labels easily
|
||||
@recipe function f(pc::PortfolioComposition)
|
||||
weights, returns = pc.args
|
||||
n = length(returns)
|
||||
weights = cumsum(weights, dims = 2)
|
||||
seriestype := :shape
|
||||
|
||||
# create a filled polygon for each item
|
||||
for c=1:size(weights,2)
|
||||
sx = vcat(weights[:,c], c==1 ? zeros(n) : reverse(weights[:,c-1]))
|
||||
sy = vcat(returns, reverse(returns))
|
||||
@series Plots.isvertical(plotattributes) ? (sx, sy) : (sy, sx)
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user