"""

John Rachlin
DS 2001: Practicum #3

Filename: donut.py
    
Description: Visualizing the locations of various
Donut shops


"""


import matplotlib.pyplot as plt


def main():
    

    # read data from file
    filename = 'donut.txt'
    with open(filename, 'r') as infile:
        
        # Skip first two lines
        infile.readline()
        infile.readline()
        
        
        # Read data for four coffee shops
        name1 = infile.readline().strip()
        dist1 = float(infile.readline())
        rate1 = float(infile.readline())
        
        name2 = infile.readline().strip()
        dist2 = float(infile.readline())
        rate2 = float(infile.readline())

        name3 = infile.readline().strip()
        dist3 = float(infile.readline())
        rate3 = float(infile.readline())

        name4 = infile.readline().strip()
        dist4 = float(infile.readline())
        rate4 = float(infile.readline())

        # file is now closed
        
    

    # create a figure
    plt.figure(figsize=(6,4), dpi=150)

    # Plot the data points       
    plt.plot(dist1, rate1, 'X', label=name1)
    plt.plot(dist2, rate2, 'o', label=name2)
    plt.plot(dist3, rate3, 's', label=name3)
    plt.plot(dist4, rate4, '^', label=name4)
    
    # Customize the plot
    
    plt.grid()
    plt.title('Nearby Coffee Shops')
    plt.xlabel('Distance [km]')
    plt.ylabel('Rating (0-5)')    
    plt.ylim(0,5)
    plt.legend()
    
    # Render the plot and save to a file
    plt.savefig('donut.png')
    plt.show()

    

main()






