Skip to content

Commit

Permalink
Get rid of offset
Browse files Browse the repository at this point in the history
  • Loading branch information
stinodego committed Apr 16, 2024
1 parent cd29b8f commit f9d2af9
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions scripts/plot_bars.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,6 @@ def add_annotations(fig: Any, limit: int, df: pl.DataFrame) -> None:
.with_row_index()
)

# every bar in the plot has a different offset for the text
# start_offset = 22
# offsets = [start_offset + 12 * i for i in range(bar_order.height)]
offsets = [0 for _ in range(bar_order.height)]

# we look for the solutions that surpassed the limit
# and create a text label for them
df = (
Expand All @@ -188,13 +183,13 @@ def add_annotations(fig: Any, limit: int, df: pl.DataFrame) -> None:

# then we create a dictionary similar to something like this:
# anno_data = {
# "q1": (offset, "label"),
# "q3": (offset, "label"),
# "q1": "label",
# "q3": "label",
# }
if df.height > 0:
anno_data = {
v[0]: (offsets[int(v[1])], v[2])
for v in df.select("query", "index", "labels")
v[0]: v[1]
for v in df.select("query", "labels")
.transpose()
.to_dict(as_series=False)
.values()
Expand All @@ -203,12 +198,12 @@ def add_annotations(fig: Any, limit: int, df: pl.DataFrame) -> None:
# a dummy with no text
anno_data = {"q1": (0, "")}

for q_name, (x_shift, anno_text) in anno_data.items():
for q_name, anno_text in anno_data.items():
fig.add_annotation(
align="right",
x=q_name,
y=LIMIT,
xshift=x_shift,
xshift=0,
yshift=30,
# font={"color": "white"},
showarrow=False,
Expand Down

0 comments on commit f9d2af9

Please sign in to comment.