Skip to content

plots for rq2#2

Open
manaalm wants to merge 1 commit into
mainfrom
rq2-manaal
Open

plots for rq2#2
manaalm wants to merge 1 commit into
mainfrom
rq2-manaal

Conversation

@manaalm

@manaalm manaalm commented Apr 10, 2026

Copy link
Copy Markdown
Collaborator

added plots for rq2

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds a new script, scripts/plotsforrq2.py, for generating standardized bar plots from research data. The review feedback recommends several improvements: updating the default output directory for consistency with the project structure, sanitizing generated filenames by converting them to lowercase and replacing spaces with underscores, and wrapping the script's execution logic in a main block to adhere to Python best practices.

Comment thread scripts/plotsforrq2.py
# -----------------------------
# Plotting function
# -----------------------------
def make_bar_plot(title, counts, output_dir="barplots"):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The project structure defined in the README.md indicates that generated results and figures should be stored in the output/ directory. Updating the default output_dir to a subdirectory within output/ ensures consistency with the repository's organization.

Suggested change
def make_bar_plot(title, counts, output_dir="barplots"):
def make_bar_plot(title, counts, output_dir="output/rq2_plots"):

Comment thread scripts/plotsforrq2.py

plt.tight_layout()

filename = os.path.join(output_dir, f"{title}.png")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using titles with spaces and mixed casing directly as filenames can lead to issues in some environments or when using command-line tools. It is recommended to sanitize the filename by converting it to lowercase and replacing spaces with underscores.

Suggested change
filename = os.path.join(output_dir, f"{title}.png")
filename = os.path.join(output_dir, f"{title.lower().replace(' ', '_')}.png")

Comment thread scripts/plotsforrq2.py
Comment on lines +114 to +122
for rq_name, counts in standardized_data.items():
make_bar_plot(rq_name, counts)

# -----------------------------
# Print standardized totals
# -----------------------------
print("\nStandardized totals:")
for rq_name, counts in standardized_data.items():
print(f"{rq_name}: total = {sum(counts.values())}, counts = {counts}") No newline at end of file

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

It is a best practice in Python to wrap the script's execution logic within an if __name__ == "__main__": block. This prevents the code from running automatically if the script is imported as a module elsewhere.

Suggested change
for rq_name, counts in standardized_data.items():
make_bar_plot(rq_name, counts)
# -----------------------------
# Print standardized totals
# -----------------------------
print("\nStandardized totals:")
for rq_name, counts in standardized_data.items():
print(f"{rq_name}: total = {sum(counts.values())}, counts = {counts}")
if __name__ == "__main__":
for rq_name, counts in standardized_data.items():
make_bar_plot(rq_name, counts)
# -----------------------------
# Print standardized totals
# -----------------------------
print("\\nStandardized totals:")
for rq_name, counts in standardized_data.items():
print(f"{rq_name}: total = {sum(counts.values())}, counts = {counts}")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant