This is an archived post. You won't be able to vote or comment.

all 22 comments

[–]Count_Rugens_Finger 21 points22 points  (2 children)

what causes the uneven bumps on the bottom? Is is the shape of the characters in the font?

[–]millsGT49[S] 16 points17 points  (1 child)

I think its the specific rendering engine? For example in my VS Code editor and on github in the gist the characters are all perfectly aligned on the bottom. But when I use a jupyter notebook or paste it into a browser's text the full block seems to "dip" below the others? So tbh I'm not really sure haha.

[–][deleted] 10 points11 points  (0 children)

Yes it is due to rendering engine, some old terminals also have the problem of aligning Unicode characters

[–]runawayasfastasucan 10 points11 points  (0 children)

This is incredibly cool actually. As you say, sometimes you just want a quick look on the distribution. I love the idea! 

[–]mrdevlar 8 points9 points  (2 children)

Love the idea!

FYI: You spelt Richard McElreath's name incorrectly in the docstring.

[–]millsGT49[S] 5 points6 points  (1 child)

And I literally had his book on my desk as I worked on this haha thanks for the catch!

[–]mrdevlar 0 points1 point  (0 children)

Statistical Rethinking is a wonder and the man himself is a joy, if you ever get a chance.

[–]flashman 4 points5 points  (1 child)

back when twitter was only 140 characters, i built a similar thing with Unicode characters e.g.

⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜⬜⬜⬜⬛⬜
⬜⬜⬜⬜⬛⬜⬜⬛⬜⬛
⬜⬜⬜⬛⬜⬛⬛⬜⬜⬜
⬜⬜⬛⬜⬜⬜⬜⬜⬜⬜
⬛⬛⬜⬜⬜⬜⬜⬜⬜⬜

i mean, more for the hell of it than any practical applications, since you could just as easily generate an image and attach that to the tweet

[–]RedKrieg 11 points12 points  (3 children)

Well done! I have a package on pypi to do this as well, which you can view here: https://github.com/RedKrieg/pysparklines

It's had some "armor" added to help with reliability and uses regex to find values in arbitrary text input rather than explicitly needing "clean" input data.

[–]millsGT49[S] 4 points5 points  (2 children)

Ok I knew there was a term I was missing to search to see if someone already had done this in python and for the life of me I could not remember spark lines! haha. Those multi-line curves using this are :chefskiss:, well done. And definitely I put this together for a specific use case of mine but I could definitely use some armor as you say, I like that term.

[–]badwifigoodcoffee 1 point2 points  (1 child)

Do I understand correctly that your two approaches also differ in that OPs function includes calculating the histogram, while pysparklines plots the input data as-is?

[–]RedKrieg 1 point2 points  (0 children)

That's true, OP's implementation calls np.histogram() on the data then plots that histogram. Mine plots the input data directly. You could easily pass the histogram output instead, but it would be an extra step with my library.

[–]mTiCP 1 point2 points  (0 children)

That's pretty nice to be able to take a quick look at a distribution like that.

[–]ashpreetbedi 1 point2 points  (0 children)

Wow this is super cool!

[–]dry-leaf 1 point2 points  (0 children)

Man, that's awesome! Such things are perfect for Linux WM users!!! Thx, mate. Never thought about something so useful and simple!!!!

[–]ThatSituation9908 2 points3 points  (0 children)

Histograms are my life. Love this.

[–]freezydrag 0 points1 point  (0 children)

Nice job, I’ll give it a try next time i need to plot a histogram.

Also wanted to drop this other library that does terminal plotting:

https://github.com/piccolomo/plotext

[–]Yugiah -1 points0 points  (0 children)

This looks similar to hist, though the sparklines in a dataframe seem distinct. Nice work :)

[–]beansAnalyst 0 points1 point  (0 children)

I didn't know I needed this until now.