Search code examples
pythonscatter

Importing data into a scatter plot


I have a code that generates every possible outcome two types of cards, each reveal showing 6-10 cards. Here is the code:

from sequence import deckOrder

for i in range(len(deckOrder)):
   for j in range(len(deckOrder)):

#Draw

first_draw = deckOrder[i]
second_draw = deckOrder[j]

#Before first draw

initial_estimate = 0.5
initial_variance = 1/12

#After first draw 

r_count = first_draw.count('R')
b_count = first_draw.count('B')


alpha = 1 + r_count
beta = 1 + b_count


e_of_theta = alpha/(alpha+beta)

surprise = ((e_of_theta - initial_estimate)**2)/(initial_variance)

var_theta = (alpha * beta)/ ((alpha + beta) **2 *(alpha + beta + 1))

#After second draw 

r_count = second_draw.count('R')
b_count = second_draw.count('B')

new_alpha = alpha + r_count 
new_beta = beta + b_count 

new_e_of_theta = new_alpha/(new_alpha + new_beta)

surprise = ((new_e_of_theta - e_of_theta)**2)/var_theta

#Result
new_list = [surprise]

I put the data into a list, but I don't know how to put the outcomes generated by this code into a scatter plot. Can someone please help me with this?


Solution

  • To put simple numbers into a scatter plot, define x and y coordinates:

    import matplotlib.pyplot as plt
    import numpy as np
    
    x = np.array([1,2,3])
    y = np.array([50,51,52])
    
    plt.scatter(x, y)
    plt.show()