dimanche 2 juin 2019

How can I plot multiple lines in a range?

Just a curiosity beginner programming question. I want to plot 100 different lists in 1 figure. It's for a game where you choose your starting capital and stake per coin flip. Every time the coin lands on head you double your stake and every-time you loose, you will loose this stake. Is there an easier way than defining y1 till y100? Is the script below only the first row of coin flips is defined and plotted

I'm trying to do this with the bokeh plotting instead of matplot.

from bokeh.plotting import figure, show, output_file
import random
startcapital=int(input("What's the start capital?:"))
bet=int(input("What's the stakes?:"))
ioutcome=[]
outcome=[]
for i in range (100):
outcomei=[]
for i in range(10):
    i=random.randint(0,1)
    ioutcome.append(i)
    if startcapital>0:
        if i==1:
            startcapital+=bet
        if i==0:
            startcapital-=bet
    outcomei.append(startcapital)
outcome.append(outcomei)
x=[1,2,3,4,5,6,7,8,9,10]
y=outcome[1]
p = figure(plot_width=800, plot_height=400)
p.line(x, y, line_width=2)
show(p)




Aucun commentaire:

Enregistrer un commentaire