#!/usr/bin/gnuplot set datafile separator "," set terminal png transparent size 800,400 do for [ac in "global-historical investing-us_large investing-us_small_value investing-3x_us_large_current investing-3x_us_large_historical leveraged_etfs-3x_us_large_current leveraged_etfs-3x_us_large_historical leveraged_etfs-2x_us_large_current leveraged_etfs-2x_us_large_historical"] { # set xlabel "years" # set xrange [0:50] # set format x "%g" # set ylabel "annual return (geometric mean)" # set yrange [-8:12] # set format y "%.0f%%" # set key right bottom # set output "investing-" . ac . "-risk_percentiles.png" # plot \ # "investing-" . ac . "-risk_percentiles.csv" using 1:($3*100) with lines title "1st percentile", \ # "investing-" . ac . "-risk_percentiles.csv" using 1:($4*100) with lines title "5th percentile", \ # "investing-" . ac . "-risk_percentiles.csv" using 1:($5*100) with lines title "20th percentile", \ # "investing-" . ac . "-risk_percentiles.csv" using 1:($6*100) with lines title "50th percentile" # # "investing-" . ac . "-risk_percentiles.csv" using 1:($2*100) with lines title "mean" set xlabel "annual return (geometric mean)" set xrange [*:*] set format x "%g%%" set ylabel "probability" set yrange [0:*] unset ytics set output ac . "-annualized_roi_pdf.png" plot \ ac . "-annualized_roi_pdf.csv" using ($1*100):2 with lines title "10 years", \ ac . "-annualized_roi_pdf.csv" using ($1*100):3 with lines title "20 years", \ ac . "-annualized_roi_pdf.csv" using ($1*100):4 with lines title "50 years" set ylabel "cummulative probability" set yrange [0:100] set format y "%g%%" set ytics set output ac . "-annualized_roi_cdf.png" plot \ ac . "-annualized_roi_cdf.csv" using ($1*100):($2*100) with lines title "10 years", \ ac . "-annualized_roi_cdf.csv" using ($1*100):($3*100) with lines title "20 years", \ ac . "-annualized_roi_cdf.csv" using ($1*100):($4*100) with lines title "50 years" set xlabel "final portfolio size / initial portfolio size" set xrange [0:*] set format x "%g" set ylabel "probability" set yrange [0:1] unset ytics set output ac . "-final_value_factor_pdf.png" plot \ ac . "-final_value_factor_pdf.csv" using 1:2 with lines title "10 years", \ ac . "-final_value_factor_pdf.csv" using 1:3 with lines title "20 years", \ ac . "-final_value_factor_pdf.csv" using 1:4 with lines title "50 years" set ylabel "cummulative probability" set yrange [0:100] set format y "%g%%" set ytics set output ac . "-final_value_factor_cdf.png" plot \ ac . "-final_value_factor_cdf.csv" using 1:($2*100) with lines title "10 years", \ ac . "-final_value_factor_cdf.csv" using 1:($3*100) with lines title "20 years", \ ac . "-final_value_factor_cdf.csv" using 1:($4*100) with lines title "50 years" } do for [years in "10 20 50"] { if (years == "10") { y_index = 2 } else { if (years == "20") { y_index = 3 } else { y_index = 4 } } set ylabel "probability" set yrange [0:0.7] unset ytics set xlabel "final portfolio size / initial portfolio size" set xrange [0:*] set format x "%g" set output "leveraged_etfs-current-years" . years . "-final_value_factor_pdf.png" plot \ "investing-us_large-final_value_factor_pdf.csv" using 1:y_index with lines title "Projected U.S. large index", \ "leveraged_etfs-2x_us_large_current-final_value_factor_pdf.csv" using 1:y_index with lines title "Projected 2X ETF", \ "leveraged_etfs-3x_us_large_current-final_value_factor_pdf.csv" using 1:y_index with lines title "Projected 3X ETF" set output "leveraged_etfs-historical-years" . years . "-final_value_factor_pdf.png" plot \ "investing-us_large-final_value_factor_pdf.csv" using 1:y_index with lines title "Projected U.S. large index", \ "leveraged_etfs-2x_us_large_historical-final_value_factor_pdf.csv" using 1:y_index with lines title "Projected 2X ETF", \ "leveraged_etfs-3x_us_large_historical-final_value_factor_pdf.csv" using 1:y_index with lines title "Projected 3X ETF" set ytics # set xlabel "annual return (geometric mean)" # set xrange [-20:40] # set format x "%.0f%%" } # Can't do "using 1:($y_index*100)", so have to unroll. set xlabel "final portfolio size / initial portfolio size" set xrange [0:*] set format x "%g" set ylabel "cummulative probability" set yrange [0:100] set format y "%g%%" set ytics set output "leveraged_etfs-current-years" . "10" . "-final_value_factor_cdf.png" plot \ "investing-us_large-final_value_factor_cdf.csv" using 1:($2*100) with lines title "Projected U.S. large index", \ "leveraged_etfs-2x_us_large_current-final_value_factor_cdf.csv" using 1:($2*100) with lines title "Projected 2X ETF", \ "leveraged_etfs-3x_us_large_current-final_value_factor_cdf.csv" using 1:($2*100) with lines title "Projected 3X ETF" set output "leveraged_etfs-historical-years" . "10" . "-final_value_factor_cdf.png" plot \ "investing-us_large-final_value_factor_cdf.csv" using 1:($2*100) with lines title "Projected U.S. large index", \ "leveraged_etfs-2x_us_large_historical-final_value_factor_cdf.csv" using 1:($2*100) with lines title "Projected 2X ETF", \ "leveraged_etfs-3x_us_large_historical-final_value_factor_cdf.csv" using 1:($2*100) with lines title "Projected 3X ETF" set output "leveraged_etfs-current-years" . "20" . "-final_value_factor_cdf.png" plot \ "investing-us_large-final_value_factor_cdf.csv" using 1:($3*100) with lines title "Projected U.S. large index", \ "leveraged_etfs-2x_us_large_current-final_value_factor_cdf.csv" using 1:($3*100) with lines title "Projected 2X ETF", \ "leveraged_etfs-3x_us_large_current-final_value_factor_cdf.csv" using 1:($3*100) with lines title "Projected 3X ETF" set output "leveraged_etfs-historical-years" . "20" . "-final_value_factor_cdf.png" plot \ "investing-us_large-final_value_factor_cdf.csv" using 1:($3*100) with lines title "Projected U.S. large index", \ "leveraged_etfs-2x_us_large_historical-final_value_factor_cdf.csv" using 1:($3*100) with lines title "Projected 2X ETF", \ "leveraged_etfs-3x_us_large_historical-final_value_factor_cdf.csv" using 1:($3*100) with lines title "Projected 3X ETF" set output "leveraged_etfs-current-years" . "50" . "-final_value_factor_cdf.png" plot \ "investing-us_large-final_value_factor_cdf.csv" using 1:($4*100) with lines title "Projected U.S. large index", \ "leveraged_etfs-2x_us_large_current-final_value_factor_cdf.csv" using 1:($4*100) with lines title "Projected 2X ETF", \ "leveraged_etfs-3x_us_large_current-final_value_factor_cdf.csv" using 1:($4*100) with lines title "Projected 3X ETF" set output "leveraged_etfs-historical-years" . "50" . "-final_value_factor_cdf.png" plot \ "investing-us_large-final_value_factor_cdf.csv" using 1:($4*100) with lines title "Projected U.S. large index", \ "leveraged_etfs-2x_us_large_historical-final_value_factor_cdf.csv" using 1:($4*100) with lines title "Projected 2X ETF", \ "leveraged_etfs-3x_us_large_historical-final_value_factor_cdf.csv" using 1:($4*100) with lines title "Projected 3X ETF"