1515import numpy as np
1616import pandas as pd
1717from PIL import Image
18- from matplotlib import pyplot as plt
18+ from matplotlib import pyplot as plt , colors
1919import seaborn as sns
2020import matplotlib
2121import plotnine
@@ -124,7 +124,6 @@ def __init__(self, graph_tools):
124124 self ._tools = graph_tools
125125 self ._wecc_states = None
126126 self ._center_points = None
127- self ._figure_size = (11 , 12 )
128127 self ._shapely = None
129128 self ._geopandas = None
130129
@@ -216,7 +215,7 @@ def graph_pie_chart(self, df, max_size=2500):
216215 current_max_size = df .groupby ("gen_load_zone" )["value" ].sum ().max ()
217216 df ["value" ] *= max_size / current_max_size
218217
219- ax = self ._tools .get_axes (size = self . _figure_size )
218+ ax = self ._tools .get_axes ()
220219 self ._plot_states (ax )
221220 df = df .merge (center_points , on = "gen_load_zone" )
222221
@@ -232,15 +231,41 @@ def graph_pie_chart(self, df, max_size=2500):
232231 ratios = (group_sum / total_size ).values
233232 GraphMapTools ._pie_plot (x , y , ratios , tech_color , ax = ax , size = total_size )
234233
235- def graph_transmission (self , df ):
234+ def graph_points (self , df , ax = None ):
235+ """
236+ Graphs a point in each load zone based on a dataframe with two columns
237+ - gen_load_zone
238+ - value
239+ """
240+ _ , center_points = self ._load_maps ()
241+
242+ df = df .merge (center_points , on = "gen_load_zone" )
243+ # Cast to GeoDataFrame
244+ df = self ._geopandas .GeoDataFrame (
245+ df [["geometry" , "value" ]], geometry = "geometry"
246+ )
247+
248+ if ax is None :
249+ ax = self ._tools .get_axes ()
250+ self ._plot_states (ax )
251+ df .plot (
252+ ax = ax ,
253+ column = "value" ,
254+ legend = True ,
255+ cmap = "coolwarm" ,
256+ markersize = 30 ,
257+ norm = colors .CenteredNorm (),
258+ )
259+
260+ def graph_transmission (self , df , cutoff ):
236261 """
237262 Graphs the data frame a dataframe onto a map.
238263 The dataframe should have 4 columns:
239264 - from: the load zone where we're starting from
240265 - to: the load zone where we're going to
241266 - value: the value to plot
242267 """
243- ax = self ._tools .get_axes (size = self . _figure_size )
268+ ax = self ._tools .get_axes ()
244269 _ , center_points = self ._load_maps ()
245270
246271 # Merge duplicate rows if table was unidirectional
@@ -265,12 +290,21 @@ def make_line(r):
265290 return LineString ([r ["from_geometry" ], r ["to_geometry" ]])
266291
267292 df ["geometry" ] = df .apply (make_line , axis = 1 )
293+ # Cast to GeoDataFrame
268294 df = self ._geopandas .GeoDataFrame (
269295 df [["geometry" , "value" ]], geometry = "geometry"
270296 )
271297
272298 self ._plot_states (ax )
273- df .plot (ax = ax , column = "value" , legend = True , cmap = "Reds" )
299+ df .plot (
300+ ax = ax ,
301+ column = "value" ,
302+ legend = True ,
303+ cmap = "Greens" ,
304+ zorder = - 50 ,
305+ norm = colors .LogNorm (vmin = cutoff , vmax = df .value .max ()),
306+ )
307+ return ax
274308
275309
276310class TransformTools :
0 commit comments