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

Improve plotting with seaborn to scale better #53

Open
niklas-heer opened this issue Oct 18, 2022 · 2 comments
Open

Improve plotting with seaborn to scale better #53

niklas-heer opened this issue Oct 18, 2022 · 2 comments
Labels
help wanted Extra attention is needed

Comments

@niklas-heer
Copy link
Owner

niklas-heer commented Oct 18, 2022

Currently, I'm using seaborn with Python to display the results. But if a lot more languages are added, the details being displayed will become too much. I'm looking for help with displaying the results in a better way, preferably with Python and seaborn. Maybe switching to Matplotlib would be now appropriate?

def plot(df, rounds, to_file):
# Theme
sns.set(style="dark", context="paper")
sns.set_color_codes("pastel")
plt.style.use("dark_background")
# Plot
# TODO: Find a way to display the platte scale to highly accuracy better.
bar = sns.barplot(
x="average",
y="name",
data=df,
width=1,
edgecolor="black",
linewidth=2,
errwidth=0,
log=True,
# TODO: Improve color palette.
# https://seaborn.pydata.org/tutorial/color_palettes.html
palette=colors_from_values(df["accuracy"], "light:seagreen"),
)
bar.bar_label(
bar.containers[0],
fontsize=10,
padding=3,
)
plt.xlabel("Average time (ms) in log scale", fontweight="bold")
plt.ylabel("Language", fontweight="bold")
# Title
plt.suptitle(
"Speed comparison of various programming languages\n",
fontweight="bold",
fontsize=20,
y=1.02,
)
plt.title(
f"Method: calculating π through the Leibniz formula {rounds} times",
style="italic",
fontsize=16,
y=1.02,
)
# Caption
url = f"https://github.com/niklas-heer/speed-comparison"
plt.figtext(
0.5, -0.1, url, wrap=True, horizontalalignment="left", fontsize=12
)
timestamp = f"Generated: {datetime.now().strftime('%Y-%m-%d %H:%M')}"
plt.figtext(
0.2,
-0.1,
timestamp,
wrap=True,
horizontalalignment="right",
fontsize=12,
)
sns.despine()
plt.autoscale()
plt.savefig(to_file, pad_inches=0.2, bbox_inches="tight", dpi=200)

@niklas-heer niklas-heer added the help wanted Extra attention is needed label Oct 18, 2022
@niklas-heer niklas-heer changed the title Help with seaborn and plotting wanted Improve plotting with seaborn to scale better Oct 18, 2022
@joelandman
Copy link
Contributor

I've not used seaborn. Will look at that. I noted that the first digit on the top set of results seems to be truncated.

I'll play with this later tonight after work, and see if I can help with it.

@niklas-heer
Copy link
Owner Author

Thank you, @joelandman that is much appreciated. Seaborn is as far as I've seen just a Matplotlib which understands dataframes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants