Skip to content

Commit

Permalink
Adjust plot margin
Browse files Browse the repository at this point in the history
  • Loading branch information
qinip committed Sep 15, 2024
1 parent 4736a88 commit c85dfb2
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 31 deletions.
1 change: 1 addition & 0 deletions docs/plot1/pci_nko_fg1.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def create_nko_plotly_figure():
# Layout
layout = go.Layout(
# title="Policy Change Index for North Korea",
margin=dict(l=50, r=50, t=20, b=50),
showlegend=False,
hovermode="x",
hoverdistance=16,
Expand Down
62 changes: 31 additions & 31 deletions docs/plot2/pci_nko_fg2.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@ def plot_policy_percentages(csv_file, output_path):
visible=True)
)

# Update layout
# Update layout with reduced margin to avoid empty space
fig.update_layout(
# title='Percentage of Articles by Policy Area Over Time',
# xaxis_title='Date',
margin=dict(l=50, r=50, t=20, b=50), # Adjust top margin to reduce empty space
yaxis_title='Monthly Percentage of Articles per Policy Area',
legend_title='Policy Area',
hovermode='x unified',
Expand All @@ -40,36 +39,37 @@ def plot_policy_percentages(csv_file, output_path):
),
yaxis=dict(
tickformat='.1f',
ticksuffix='%'),

)
ticksuffix='%'
),
)

# Add buttons for selecting all or none
fig.update_layout(dict(updatemenus=[
dict(
type = "buttons",
direction = "left",
buttons=list([
dict(
args=["visible", "legendonly"],
label="Unselect All",
method="restyle"
),
dict(
args=["visible", True],
label="Select All",
method="restyle"
)
]),
pad={"r": 10, "t": 10},
showactive=False,
x=1.25,
xanchor="right",
y=1.05,
yanchor="top"
),
]
))
fig.update_layout(
updatemenus=[
dict(
type="buttons",
direction="left",
buttons=[
dict(
args=["visible", "legendonly"],
label="Unselect All",
method="restyle"
),
dict(
args=["visible", True],
label="Select All",
method="restyle"
)
],
pad={"r": 10, "t": 10},
showactive=False,
x=1.25,
xanchor="right",
y=1.05,
yanchor="top"
),
]
)


# Add vertical line at 2022-01 with hover text
Expand Down

0 comments on commit c85dfb2

Please sign in to comment.