# How to show a graph with plotly dash & bootstrap?

Hi, first of all, sorry for the q. I now it’s a bit obvious, but when traying to imitate other .py strutures that use plt.(figure), I have problems. I still don’t understand how is the correct way.

I’m not showing my code, but I will show the code base.

My q is: How do I change the structure from plt to bcc.Graphs and px?

``````
# Creating Figure for Simulation Balances
fig = plt.figure()
plt.title("Monte Carlo Dice Game [" + str(num_simulations) + "
simulations]")
plt.xlabel("Roll Number")
plt.ylabel("Balance [\$]")
plt.xlim([0, max_num_rolls])

# For loop to run for the number of simulations desired
for i in range(num_simulations):
balance = [1000]
num_rolls = [0]
num_wins = 0    # Run until the player has rolled 1,000 times
while num_rolls[-1] < max_num_rolls:
same = roll_dice()        # Result if the dice are the same number
if same:
balance.append(balance[-1] + 4 * bet)
num_wins += 1
# Result if the dice are different numbers
else:
balance.append(balance[-1] - bet)

num_rolls.append(num_rolls[-1] + 1)# Store tracking variables and add line to figure
win_probability.append(num_wins/num_rolls[-1])
end_balance.append(balance[-1])
plt.plot(num_rolls, balance)

# Showing the plot after the simulations are finished
plt.show()

# Averaging win probability and end balance
overall_win_probability = sum(win_probability)/len(win_probability)
overall_end_balance = sum(end_balance)/len(end_balance)# Displaying the averages
print("Average win probability after " + str(num_simulations) + "
runs: " + str(overall_win_probability))
print("Average ending balance after " + str(num_simulations) + "
runs: \$" + str(overall_end_balance))
``````

So the source of the code you posted here seems to be this one:

the plotting library used is matplotlib.