Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor plot fixes #113

Merged
merged 1 commit into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions scripts/plot_bars.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,21 @@ def plot(df: pl.DataFrame) -> Figure:
barmode="group",
template="plotly_white",
color_discrete_sequence=color_seq,
title=get_title(settings.run.include_io, settings.run.file_type),
)

fig.update_layout(
title={
"text": get_title(settings.run.include_io, settings.run.file_type),
"y": 0.95,
"yanchor": "top",
},
bargroupgap=0.1,
# paper_bgcolor="rgba(41,52,65,1)",
xaxis_title="Query",
yaxis_title="Seconds",
yaxis_range=[0, LIMIT],
# plot_bgcolor="rgba(41,52,65,1)",
margin={"t": 100},
margin={"t": 150},
legend={
"title": "",
"orientation": "h",
Expand Down Expand Up @@ -156,7 +160,7 @@ def get_title(include_io: bool, file_type: FileType) -> str:
return f"{title}<br><i>{subtitle}<i>"


def add_annotations(fig: Any, limit: int, df: pl.DataFrame) -> None:
def add_annotations(fig: Any, limit: float, df: pl.DataFrame) -> None:
# order of solutions in the file
# e.g. ['polar', 'pandas']
bar_order = (
Expand Down Expand Up @@ -196,7 +200,7 @@ def add_annotations(fig: Any, limit: int, df: pl.DataFrame) -> None:
}
else:
# a dummy with no text
anno_data = {"q1": (0, "")}
anno_data = {"q1": ""}

for q_name, anno_text in anno_data.items():
fig.add_annotation(
Expand All @@ -205,7 +209,6 @@ def add_annotations(fig: Any, limit: int, df: pl.DataFrame) -> None:
y=LIMIT,
xshift=0,
yshift=30,
# font={"color": "white"},
showarrow=False,
text=anno_text,
)
Expand All @@ -217,9 +220,9 @@ def write_plot_image(fig: Any) -> None:
path.mkdir()

if settings.run.include_io:
file_name = "plot_with_io.html"
file_name = f"plot-io-{settings.run.file_type}.html"
else:
file_name = "plot_without_io.html"
file_name = "plot-no-io.html"

print(path / file_name)

Expand Down
4 changes: 2 additions & 2 deletions settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ class Run(BaseSettings):
class Plot(BaseSettings):
show: bool = False
n_queries: int = 7
limit_with_io: int = 20
limit_without_io: int = 15
limit_with_io: float = 20.0
limit_without_io: float = 15.0

model_config = SettingsConfigDict(
env_prefix="plot_", env_file=".env", extra="ignore"
Expand Down