Wednesday, January 29, 2025

Playing with Patches

Screen Shot 2025-01-29 at 8.10.44 PM

Whether to "chalk it up to coincidence" means anything, or not, I found it interesting to come across a ping, someone pinging me, with what looked to be a matplotlib figure. 

That prolly doesn't make much sense; lemme explain: getting good-looking plots, like bar graphs, histograms, pie charts, more exotic yet expected other statistician-invented forms (KDE plot, HeatMap), and having them be data-driven i.e. painted by numbers you're studying, is the job of a few open source tools such as matplotlib.

But then matplotlib can do so much more, providing general purpose geometric objects and control over their attributes and relative placement. A subpackage even gets into 3D (rotatable) 3-way renderings. One may enjoy hours exploring the ins and outs of this fascinating free package. Most users learn just enough to get by, as is true in my case, so I was letting Gemini shoulder the burden and boost the coding proficiency, which it did, dutifully.

The guy pinging me was on Facebook, Esteban again, regarding a narrative he has, regarding a point and/or ball and it's Flatlandesque transitions through some stairway to heaven dimensional ladder, only to start back at the beginning, somehow transformed. I'm referring to Flatland by Edwin Abbott, a satirical work about the varying degrees of awareness enjoyed by strictly dimensionally-defined beings.

Geometry in other words; we're comparing notes about circles 'n stuff. I take Abbott to be taking us through Hilbert Spaces, each rung of higher D. 

Esteban shares this graphic of mechanically perfect circles, shaded by color, semi-transparent, while meanwhile, on other nights, I'm leading a class in precisely this area: a how-to vs-a-vs matplotlib and related packages within the Python ecosystem.

I should digress and remind readers how each computer language is like "of a tribe" in that an ecosystem of users and developers emerges to staff positions and administer tribal governance. Maybe it's an inhouse language that belongs to an academic department. If you make friends there, they let you use it. Circumstances vary.

My trajectory was to see a Perl culture somewhat suffused with Python, and then with Ruby. Then Java took off. We've enjoyed a design science Renaissance, with a plague and everything! 

My portal into these undercurrents was via O'Reilly's open source conventions in Portland, Oregon. In some of those years, I was even helping staff an O'Reilly School booth, long story. Nowadays we're up to Rust and Zig. Which isn't to say some of the old die-hards aren't still around.

Open source is an umbrella term for a lot of such languages, and accounts for how they've become widely spread. Right now "open source" is in the buzz because of DeepSeek's splash debut, causing another "Sputnik moment" in the 'Murican Psyche. 

When Python takes off in Brazil and South Africa and no one is confused about why: smart language, smart peoples. The language was a product of Dutch brains in the first place. EuroPythons predate Pycons. 

Many representatives come to Pycons, which I'd also go to (in addition to OSCON). 

In the course of doing all this, I'm passing out some of the latest AI write-ups about me and what I've been up to. I know of cases where individuals have been displeased by stochastic gaffs. In my case however, with Perplexity at the helm, I wasn't disturbed by the results. Predictable. As the doctor ordered. I'm interested in curriculum and education, and have worked on some examples, such as on what I've called Martian Math.

Anyway, to continue with my story, I went onto colab.research.google.com, like I do in the class I'm leading, and asked Gemini to write me a matplotlib-using Python program that'd blend together shaded semi-transparent circles and thick black dotted lines. I prompted for that in the Gemini prompt box and got back a complete program, that ran correctly unmodified.

Matplotlib in action
The result was not diagrammatically significant, given how much it depends on random numbers, but then I wasn't aiming to produce something significant, so much as in the style of, a similarity in one dimension, we could say a tenuously narrow one.

So here's the resulting Gemini-generated graphic, in response to my prompt:

Screen Shot 2025-01-29 at 8.19.42 PM
 And what was that prompt again? 
Use matplotlib to draw a figure containing several partially overlapping circles of different colors and partial transparency, along with assorted dotted thick black lines at various angles.
Of course if I wanted it even more perfect, I could omit the spines, labels, tick marks, and take manual control of Circle placement. 

On class the night previously, we were not considering Circles at all, but Rectangles, which were used to construct the data-driven count and bar plots, even histograms, of our dreams. 

I'm harkening back to the coincidental juxtaposition of this content, with the schematics of another Facebook artist, Esteban Trev.

By the way, Circles and Rectangles are both in a taxonomy with a more umbrella term: Patches.
 
From the Docs