jmansfield89 commited on
Commit
b4e4c1d
1 Parent(s): 2abcd22

Update app.py

Browse files

Increase chart size and fix color scale issue for filter selection that includes rank

Files changed (1) hide show
  1. app.py +12 -2
app.py CHANGED
@@ -66,21 +66,31 @@ def display_filter(col_names):
66
  return filter_selection
67
 
68
 
 
69
  def display_chart(df_tr, filter):
70
  """
71
  Displays various charts of the data.
72
  """
73
- # Create chart
 
 
 
 
 
 
74
  fig = px.choropleth(df_tr,
75
  locations='State',
76
  color=filter,
77
  locationmode='USA-states', # Set to plot as US States
78
  title='2019 U.S. Energy {filter}'.format(filter=filter),
 
79
  )
80
 
81
  # Add title and set USA as boundary for map
82
- fig.update_layout(title_x=0.45,
83
  geo_scope='usa', # Plot only the USA instead of globe
 
 
84
  )
85
 
86
  # Display chart using Streamlit
 
66
  return filter_selection
67
 
68
 
69
+ # noinspection PyShadowingBuiltins
70
  def display_chart(df_tr, filter):
71
  """
72
  Displays various charts of the data.
73
  """
74
+ # Determine filter value in order to set proper color scale for chart
75
+ if 'rank' in filter.lower():
76
+ color_scale = 'plasma_r'
77
+ else:
78
+ color_scale = 'plasma'
79
+ #te
80
+ # Create chart
81
  fig = px.choropleth(df_tr,
82
  locations='State',
83
  color=filter,
84
  locationmode='USA-states', # Set to plot as US States
85
  title='2019 U.S. Energy {filter}'.format(filter=filter),
86
+ color_continuous_scale=color_scale,
87
  )
88
 
89
  # Add title and set USA as boundary for map
90
+ fig.update_layout(title_x=0.4,
91
  geo_scope='usa', # Plot only the USA instead of globe
92
+ height=800,
93
+ width=1000
94
  )
95
 
96
  # Display chart using Streamlit