Skip to content

Commit

Permalink
Make Graphs save as PDFs
Browse files Browse the repository at this point in the history
  • Loading branch information
Mcilie committed May 29, 2024
1 parent 4884033 commit ff6b994
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 15 deletions.
1 change: 1 addition & 0 deletions src/prompt_systematic_review/experiments/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@
graph_gpt_3_5_benchmarks.Experiment,
run_tomotopy.Experiment,
topicgpt.Experiment,
count_models.Experiment,
]
7 changes: 6 additions & 1 deletion src/prompt_systematic_review/experiments/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import networkx as nx
import matplotlib.pyplot as plt
import textwrap
from prompt_systematic_review.config_data import DataFolderPath


class SemanticScholarAPI:
Expand Down Expand Up @@ -85,7 +86,11 @@ def visualize_citation_counts(self, paper_references, technique_to_title):
plt.title("Citation Counts by Technique")
plt.xticks(rotation=45)
plt.tight_layout()
plt.show()
plt.savefig(
os.path.join(
DataFolderPath, "experiments_output" + os.sep + "paper_graph.pdf"
),format="pdf", bbox_inches="tight"
)


class Main:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ def graph_dataset_citations():
output_dir = os.path.join(DataFolderPath, "experiments_output")
os.makedirs(output_dir, exist_ok=True)
# output_file_path = os.path.join(output_dir, "graph_dataset_mentions_output.png")
output_file_path = os.path.join(output_dir, "graph_dataset_mentions_output.png")
output_file_path = os.path.join(output_dir, "graph_dataset_mentions_output.pdf")

plt.savefig(output_file_path)
plt.savefig(output_file_path,format="pdf", bbox_inches="tight")


class Experiment:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ def graph_gpt_3_5():
plt.savefig(
os.path.join(
DataFolderPath,
"experiments_output" + os.sep + "graph_gpt_3_5_benchmarks_output.png",
)
"experiments_output" + os.sep + "graph_gpt_3_5_benchmarks_output.pdf",
),format="pdf", bbox_inches="tight"
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ def graph_gt_4_benchmarks200():
plt.savefig(
os.path.join(
DataFolderPath,
"experiments_output" + os.sep + "graph_gpt_4_benchmarks200_output.png",
)
"experiments_output" + os.sep + "graph_gpt_4_benchmarks200_output.pdf",
),format="pdf", bbox_inches="tight"
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ def visualize_graph(self, paper_references, technique_to_title):
plt.axis("off")

# plt.show()
plt.savefig("network_graph.png", format="png", dpi=300)
plt.savefig("network_graph.pdf", format="pdf", bbox_inches="tight")

def visualize_citation_counts(self, paper_references, title_to_technique):
citation_counts = {}
Expand Down
4 changes: 2 additions & 2 deletions src/prompt_systematic_review/experiments/graph_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ def graph_models(inputFile="model_citation_counts.csv"):
os.makedirs(output_dir, exist_ok=True) # Create directory if it doesn't exist

# output_file_path = os.path.join(output_dir, "graph_models_output.png")
output_file_path = os.path.join("graph_models_output.png")
output_file_path = os.path.join("graph_models_output.pdf")

plt.savefig(output_file_path)
plt.savefig(output_file_path,format="pdf", bbox_inches="tight")


class Experiment:
Expand Down
3 changes: 2 additions & 1 deletion src/prompt_systematic_review/experiments/topicgpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ def run_topic_gpt():
plt.savefig(
os.path.join(
DataFolderPath, "experiments_output" + os.sep + "topic_distribution.png"
)
),
format="pdf", bbox_inches="tight"
)


Expand Down
9 changes: 5 additions & 4 deletions src/prompt_systematic_review/experiments/visualize_authors.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ def visualize_authors():
plt.savefig(
os.path.join(
DataFolderPath,
"experiments_output" + os.sep + "publication_frequency_by_author.png",
)
"experiments_output" + os.sep + "publication_frequency_by_author.pdf",
), format="pdf", bbox_inches="tight"
)

# Display the frequency table
Expand Down Expand Up @@ -76,8 +76,9 @@ def visualize_authors():
plt.savefig(
os.path.join(
DataFolderPath,
"experiments_output" + os.sep + "publication_count_vs_frequency.png",
)
"experiments_output" + os.sep + "publication_count_vs_frequency.pdf",
),
format="pdf", bbox_inches="tight"
)


Expand Down

0 comments on commit ff6b994

Please sign in to comment.