Skip to content

Commit

Permalink
Merge pull request #162 from trigaten/pdf_graphs_doc
Browse files Browse the repository at this point in the history
Make Graphs save as PDFs
  • Loading branch information
hudssntao authored May 29, 2024
2 parents 07bd0f6 + 2e36258 commit 2e809f5
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 18 deletions.
4 changes: 1 addition & 3 deletions src/prompt_systematic_review/experiments/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,5 @@
graph_gpt_3_5_benchmarks.Experiment,
run_tomotopy.Experiment,
topicgpt.Experiment,
download_mmlu.Experiment,
graph_internal_references.Experiment,
graph.Experiment,
count_models.Experiment,
]
9 changes: 8 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,13 @@ 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 @@ -87,9 +87,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,10 @@ 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,10 @@ 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 @@ -333,7 +333,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
4 changes: 3 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,9 @@ def run_topic_gpt():
plt.savefig(
os.path.join(
DataFolderPath, "experiments_output" + os.sep + "topic_distribution.png"
)
),
format="pdf",
bbox_inches="tight",
)


Expand Down
12 changes: 8 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,10 @@ 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 +78,10 @@ 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 2e809f5

Please sign in to comment.