Skip to content

Commit dc94648

Browse files
Add adjustments
1 parent 8198ee3 commit dc94648

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

policyengine/outputs/macro/single/gov/local_areas/local_authorities.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def local_authorities(
5151

5252
sim = simulation.selected_sim
5353
original_hh_weight = sim.calculate("household_weight").values
54-
metric(simulation.selected)
54+
metric(sim)
5555

5656
for constituency_id in range(weights.shape[0]):
5757
sim.set_input(

policyengine/outputs/macro/single/gov/local_areas/parliamentary_constituencies.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def parliamentary_constituencies(
5151

5252
sim = simulation.selected_sim
5353
original_hh_weight = sim.calculate("household_weight").values
54-
metric(simulation.selected)
54+
metric(sim)
5555

5656
for constituency_id in range(weights.shape[0]):
5757
sim.set_input(

policyengine/utils/charts.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,15 @@ def get_version_number(package):
4545
return pkg_resources.get_distribution(package).version
4646

4747

48-
def format_fig(fig: go.Figure, country: str = "uk") -> go.Figure:
48+
def format_fig(
49+
fig: go.Figure, country: str = "uk", add_zero_line: bool = False
50+
) -> go.Figure:
4951
"""Format a plotly figure to match the PolicyEngine style guide.
5052
5153
Args:
5254
fig (go.Figure): A plotly figure.
55+
country (str): The country for which the style guide should be applied.
56+
add_zero_line (bool): Whether to add a zero line to the plot.
5357
5458
Returns:
5559
go.Figure: A plotly figure with the PolicyEngine style guide applied.
@@ -70,7 +74,10 @@ def format_fig(fig: go.Figure, country: str = "uk") -> go.Figure:
7074
paper_bgcolor=LIGHT_LIGHT_GRAY, # set paper background color to white
7175
# No white grid marks
7276
xaxis=dict(gridcolor=LIGHT_LIGHT_GRAY, zerolinecolor=LIGHT_LIGHT_GRAY),
73-
yaxis=dict(gridcolor=LIGHT_LIGHT_GRAY, zerolinecolor=DARK_GRAY),
77+
yaxis=dict(
78+
gridcolor=LIGHT_LIGHT_GRAY,
79+
zerolinecolor=DARK_GRAY if add_zero_line else LIGHT_LIGHT_GRAY,
80+
),
7481
)
7582

7683
fig.add_layout_image(

policyengine/utils/maps.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,17 @@ def plot_hex_map(value_by_area_name: dict, location_type: str) -> dict:
1515
local_folder=None,
1616
version=None,
1717
)
18+
x_bounds = [30, 85]
19+
y_bounds = [-50, 2]
1820
elif location_type == "local_authorities":
1921
area_names_file_path = download(
2022
repo="policyengine/policyengine-uk-data",
2123
repo_filename="local_authorities_2021.csv",
2224
local_folder=None,
2325
version=None,
2426
)
27+
x_bounds = [-20, 25]
28+
y_bounds = [-10, 35]
2529
else:
2630
raise ValueError("Invalid location_type: " + location_type)
2731
area_names = pd.read_csv(area_names_file_path)
@@ -65,11 +69,11 @@ def plot_hex_map(value_by_area_name: dict, location_type: str) -> dict:
6569
yaxis_title="",
6670
xaxis_range=[expanded_lower_x_range, expanded_upper_x_range],
6771
yaxis_range=[
68-
constituency_names["y"].min(),
69-
constituency_names["y"].max(),
72+
area_names["y"].min(),
73+
area_names["y"].max(),
7074
],
7175
).update_traces(marker_size=10).update_layout(
72-
xaxis_range=[30, 85], yaxis_range=[-50, 2]
76+
xaxis_range=x_bounds, yaxis_range=y_bounds
7377
)
7478

7579
x_min = fig.data[0]["marker"]["color"].min()

0 commit comments

Comments
 (0)