import pandas as pd import plotly.express as px import plotly.graph_objects as go # Data collected from previous steps data = { "Institution": [ "Princeton", "MIT", "Harvard", "Stanford", "Yale", "Cal Tech", "Duke", "Johns Hopkins", "Northwestern", "Penn", "Cornell", "U Chicago", "Columbia", "Brown", "Dartmouth", "UCLA", "UC Berkeley", "Rice", "Notre Dame", "Vanderbilt", "Carnegie Mellon", "U Michigan", "Wash U", "Emory", "Georgetown", "UVA", "USC", "Texas", "Ohio State", "U Georgia", "Texas A&M", "Florida State", "NC State", "Miami", "Penn State", "Clemson", "Iowa", "Arizona", "Missouri", "Oregon", "Tennessee", "U Oklahoma", "Utah", "Kansas", "Kansas State", "Bama", "Ole Miss", "LSU", "Oklahoma State" ], "US News Ranking 24-25": [ 1, 2, 3, 3, 5, 6, 7, 9, 9, 7, 12, 12, 12, 15, 18, 18, 15, 17, 18, 18, 22, 21, 24, 24, 22, 24, 28, 32, 43, 43, 47, 53, 60, 67, 60, 77, 82, 115, 124, 98, 105, 124, 105, 151, 170, 115, 151, 173, 195 ], "US News Ranking 23-24": [ 1, 2, 3, 3, 5, 6, 7, 9, 9, 7, 12, 12, 12, 15, 18, 18, 15, 17, 18, 18, 22, 21, 24, 24, 22, 24, 28, 32, 43, 43, 47, 53, 60, 67, 60, 77, 82, 115, 124, 98, 105, 124, 105, 151, 170, 115, 151, 173, 195 ], "FIRE Ranking 24-25": [ 11, None, 248, 118, 164, 15, 186, 216, 138, 167, 106, 2, 240, 171, 155, 160, 182, 10, 18, 188, 153, 180, 139, 189, 166, 22, 245, 154, 199, 16, 21, 45, 47, 41, 151, 7, 210, 222, 19, 195, 88, 13, 198, 185, 4, 143, 3, 5, 23 ], "FIRE Ranking 23-24": [ None, 23, 185, 114, 78, None, 123, 125, 76, 106, 62, 11, 121, 116, 122, 110, 147, 22, 31, 128, 102, 109, 97, 104, 108, 4, 189, 141, 166, 21, 10, 53, 51, 48, 143, 11, 172, 179, 28, 169, 87, 11, 156, 157, 8, 101, 4, 5, 15 ], "ADL Grade 24-25": [ 1.0, 0.0, 0.0, 0.0, 1.0, None, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 3.0, None, None, None, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 1.0, None, None, None, 1.0, 1.0, None, None, 1.0, None, None, 1.0, 1.0, None, None, None, None, 1.0, None, None ], "ADL Grade 23-24": [ None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None ], "NCAA Football Ranking 24-25": [ None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None ], "NCAA Football Ranking 23-24": [ None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 14, None, None, 1, None, None, None, None, None, 3, 7, 4, None, 6, 18, None, 13, 20, 24, 11, 8, 9, 17, 15, 21, 23, None, 5, 9, 12, 16 ], "NCAA Basketball Ranking 24-25": [ None, None, None, None, None, None, 17, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 21, None, None, None, None, None, None, None, None ], "NCAA Basketball Ranking 23-24": [ None, None, None, None, None, None, None, None, 21, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 23, None, None, None, None, None, None, None, None, None, None, None, None, None, 24, 10, None, None, 2, 15, None, None, None, None ], } df = pd.DataFrame(data) # Fill 'NR' values with None for plotting df = df.replace("NR", None).infer_objects(copy=False) # Get the list of all numeric columns to be used as options for the dropdowns numerical_columns = [ col for col in df.columns if pd.api.types.is_numeric_dtype(df[col]) ] # Create the initial scatter plot figure fig = px.scatter( df, x=numerical_columns[0], y=numerical_columns[1], hover_name="Institution", custom_data=df.iloc[:, 1:].columns, color_discrete_sequence=px.colors.qualitative.Plotly ) # Function to create buttons for dropdowns def create_dropdown_buttons(axis_list, initial_value): buttons = [] for axis in axis_list: button = dict( label=axis, method='update', args=[ {'x': [df[axis]]} if axis == initial_value else {'y': [df[axis]]}, {'xaxis.title.text': axis} if axis == initial_value else {'yaxis.title.text': axis} ] ) buttons.append(button) return buttons # Create dropdown buttons for X and Y axes x_buttons = [ {'label': col, 'method': 'update', 'args': [{'x': [df[col]]}, {'xaxis.title.text': col}]} for col in numerical_columns ] y_buttons = [ {'label': col, 'method': 'update', 'args': [{'y': [df[col]]}, {'yaxis.title.text': col}]} for col in numerical_columns ] # Add dropdown menus to the figure fig.update_layout( updatemenus=[ dict( buttons=x_buttons, direction="down", pad={"r": 10, "t": 10}, showactive=True, x=0.1, xanchor="left", y=1.15, yanchor="top" ), dict( buttons=y_buttons, direction="down", pad={"r": 10, "t": 10}, showactive=True, x=0.5, xanchor="left", y=1.15, yanchor="top" ), ] ) # Custom hover template to show all data (now using customdata array) customdata_labels = df.columns[1:].tolist() hover_template = "%{hover_name}

" for i, label in enumerate(customdata_labels): hover_template += f"{label}: " + "%{{customdata[{}]}}".format(i) + "
" hover_template += "" fig.update_traces(hovertemplate=hover_template) # Save the final interactive plot to an HTML file fig.write_html("interactive_university_chart.html") print("Interactive chart has been generated and saved to 'interactive_university_chart.html'")
top of page

College Sports, Freedom of Speech, and the Jewish Question

Our 
Story

Basics: American Jews should start looking at southern schools, athletic powerhouses, and schools with high Christian populations

Let’s Work Together

500 Terry Francine Street 

San Francisco, CA 94158

Tel: 123-456-7890

  • Facebook
  • Twitter
  • LinkedIn
  • Instagram

Thanks for submitting!

bottom of page