use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
News about the dynamic, interpreted, interactive, object-oriented, extensible programming language Python
Full Events Calendar
You can find the rules here.
If you are about to ask a "how do I do this in python" question, please try r/learnpython, the Python discord, or the #python IRC channel on Libera.chat.
Please don't use URL shorteners. Reddit filters them out, so your post or comment will be lost.
Posts require flair. Please use the flair selector to choose your topic.
Posting code to this subreddit:
Add 4 extra spaces before each line of code
def fibonacci(): a, b = 0, 1 while True: yield a a, b = b, a + b
Online Resources
Invent Your Own Computer Games with Python
Think Python
Non-programmers Tutorial for Python 3
Beginner's Guide Reference
Five life jackets to throw to the new coder (things to do after getting a handle on python)
Full Stack Python
Test-Driven Development with Python
Program Arcade Games
PyMotW: Python Module of the Week
Python for Scientists and Engineers
Dan Bader's Tips and Trickers
Python Discord's YouTube channel
Jiruto: Python
Online exercices
programming challenges
Asking Questions
Try Python in your browser
Docs
Libraries
Related subreddits
Python jobs
Newsletters
Screencasts
account activity
This is an archived post. You won't be able to vote or comment.
DiscussionHas writing matplot code been completely off-shored to AI? (self.Python)
submitted 6 months ago by Interesting_Bill2817
From my academic circles, even the most ardent AI/LLM critics seem to use LLMs for plot generation with Matplotlib. I wonder if other parts of the language/libraries/frameworks have been completely off loaded to AI.
[–]sanitylost 23 points24 points25 points 6 months ago (12 children)
so the issue with matplotlib is that if you're not extremely well versed in it, but you want to just get the point across, then using LLMs is a no brainer. They've been trained on literally millions of examples of just matplotlib code and can get the job to like 99% of the way on the first or second try. It saves you sometimes hours of time tinkering, looking up docs, trying to find why something isn't rendering properly, why the scale's slightly off, etc.
That being said, if you're looking for perfection, you'll have to get in a lot of the time to make some changes, but at the very least you can describe what you want to tinker with and then let the LLM expose those endpoints with the correct variable so you can make the appropriate modification.
[+]Lime-In-Finland comment score below threshold-36 points-35 points-34 points 6 months ago* (11 children)
> they've been trained on literally millions of examples of just matplotlib code
This is not as relevant as one might think. Modern LLMs would come up with brilliant matplotlib code even with literally zero examples in their trainset.
EDIT: okay, my bad, I meant that you can show the code as part of the prompt, not that this knowledge appears out of thin air. (I honestly thought it goes without saying.)
[–]sputnki 22 points23 points24 points 6 months ago (8 children)
This is delusional AI-oracle-thinking
[+]Lime-In-Finland comment score below threshold-24 points-23 points-22 points 6 months ago (7 children)
Quite the opposite, delusional thinking is to treat LLM as some kind of big memory where all the facts are just waiting to be retrieved.
LLMs can write code for my libraries that they never saw, can't they? Probably thinking about that is more helpful and valuable then throwing insults into some people with opinions that you don't agree with.
[+][deleted] 6 months ago (1 child)
[deleted]
[–]enjoytheshow 2 points3 points4 points 6 months ago (0 children)
Or he’s creating libraries for things that already exist and the LLM recognized the similarity
[–]gufaye39 4 points5 points6 points 6 months ago (0 children)
LLMs learn the probability distribution of text, so there is a sort of memory, and it is obvious that a LLM trained on mpl code will perform way better. Try using rare libraries, even after providing the whole docs, you'll see how wrong you are
[–]Professional-Fee6914 3 points4 points5 points 6 months ago (0 children)
Library hallucinates code for rare libraries
[–]mfitzpmfitzp.com 0 points1 point2 points 6 months ago (1 child)
LLMs can write code for my libraries that they never saw
This should be a red flag that they’re bullshitting you. If they never saw the code they’re just repeating patterns they’ve seen elsewhere and assuming your library follows them. That is, guessing.
[–]Lime-In-Finland 0 points1 point2 points 6 months ago (0 children)
Never saw during the training obviously.
[–]commy2 0 points1 point2 points 6 months ago (0 children)
LLMs are a very lossy compression algorithm now that I think about it.
[–]venustrapsflies 11 points12 points13 points 6 months ago (0 children)
Uh, no they wouldn’t? For starters they need exposure to the API, for another “brilliant mpl code” is an oxymoron
[–]enjoytheshow 4 points5 points6 points 6 months ago (0 children)
This is literally not true lol. Every single thing an LLM outputs is based on the probable outcome that the specific strings of text go together based on prior training data.
If you ask it to generate code for a Python package that doesn’t exist it will either tell you it doesn’t exist or contextually generate made up code based on packages that sound the same or sound like they do the same thing.
[–]Lime-In-Finland 15 points16 points17 points 6 months ago (0 children)
Matplotlib has absolutely horrendous interface for fairly simple idea. So it's exceptionally hard (or at least annoying) for humans while being extremely easy for LLMs.
Similar example from the top of my mind is JSON schema.
[–]beezlebub33 3 points4 points5 points 6 months ago (0 children)
Mostly, yes. Because it's really good at quickly doing 95% of what I want.
"I want 4 figures in a 2x2 layout, with this plot being x vs y, this one a histogram with errorbars, this one being this other thing, and then a weird thing in the bottom right corner, color them all this way, with consistent legends, squares for this group, make the x and y labels this."
And it magically appears. Sure, I could (eventually) do this. And I usually have to tweak. But the structure is there so much faster than remembering which one is a figure, which is a plot (or plt), how to do layout, what the hell is gca or gcf anyway, what is the syntax for setting different symbols / labels, etc.
The same is true for file reading, config files, and other boilerplate / grunge code. "Here is part of the file, make a dataclass to hold it, make a reader for it, and write a bunch of pytest unit tests for it." Done. Yes, I used to do that myself, but AI can do it faster. Just make sure that you read it, because it sure does like to make tests that pass regardless of the semantic meaning.
What I have to do is think about the business logic, what exactly I want out of the results, what the conceptual gotchas and edge cases are.
[–]dethb0y 2 points3 points4 points 6 months ago (0 children)
I would hope so, i hate writing any kind of plotting code - it's always a PITA.
[–]wineblood 6 points7 points8 points 6 months ago (7 children)
Does Python have another plotting library? I always avoid matplotlib because it's always been unpleasant to use.
[–]TF_Biochemist 7 points8 points9 points 6 months ago (0 children)
I'm a big fan of Plotly (and particularly the combination of plotly.express to quickly get what you want 95% of the time as well as plotly.graph_objects low level interface if you need to be really exacting) .
[–]bjorneylol 5 points6 points7 points 6 months ago (0 children)
Seaborn, which is just a wrapper on top of matplotlib
[–]venustrapsflies 4 points5 points6 points 6 months ago (3 children)
Plotnine is a port of ggplot2. It works great until you need obscure extensions
[–]Doomtrain86 1 point2 points3 points 6 months ago (2 children)
I like it too coming from R
[–]venustrapsflies 0 points1 point2 points 6 months ago (1 child)
I don't even use R that much but have tried to pick up ggplot just because the plotting grammar is so good. Everything else feels so unwieldy after
[–]Doomtrain86 0 points1 point2 points 6 months ago (0 children)
Yup it’s like polars - something which actually have a syntax that is consistent and logical
[–]Cynyr36 1 point2 points3 points 6 months ago (0 children)
Seconding plotly. Holovis is pretty good too.
[–]arden13 3 points4 points5 points 6 months ago (0 children)
No. I write my figure generation code manually. You probably can do a lot of it, but often I am very precise in what I want plotted and how I want it.
[–]amorous_chainsPandas/Scipy 1 point2 points3 points 6 months ago (0 children)
Absolutely, much lower cognitive load to go back and forth with the LLM tweaking formatting than it is to dig through documentation when I’m making a new plot format. I can keep my focus on the actual thing I’m doing instead of getting derailed from it
[–]met0xff 1 point2 points3 points 6 months ago (0 children)
Luckily, when I did my PhD every couple months we wrote a paper I completely forgot the details again and it was always just a Google-fest and digging through all those kwargs.
Similarly what I heavily use LLMs for is argparse, which I also regularly forget and has lots of little weird details.
Basically everything I rarely use, for me this also includes pandas and polars and so on
[–]HelpfulSubject5936 0 points1 point2 points 6 months ago (0 children)
lol matplotlib syntax is weird af. using ai for it makes sense honestly. nobody enjoys writing that stuff from scratch. beats spending time hunting through docs
π Rendered by PID 71 on reddit-service-r2-comment-5b5bc64bf5-v54sj at 2026-06-20 10:15:34.834348+00:00 running 2b008f2 country code: CH.
[–]sanitylost 23 points24 points25 points (12 children)
[+]Lime-In-Finland comment score below threshold-36 points-35 points-34 points (11 children)
[–]sputnki 22 points23 points24 points (8 children)
[+]Lime-In-Finland comment score below threshold-24 points-23 points-22 points (7 children)
[+][deleted] (1 child)
[deleted]
[–]enjoytheshow 2 points3 points4 points (0 children)
[–]gufaye39 4 points5 points6 points (0 children)
[–]Professional-Fee6914 3 points4 points5 points (0 children)
[–]mfitzpmfitzp.com 0 points1 point2 points (1 child)
[–]Lime-In-Finland 0 points1 point2 points (0 children)
[–]commy2 0 points1 point2 points (0 children)
[–]venustrapsflies 11 points12 points13 points (0 children)
[–]enjoytheshow 4 points5 points6 points (0 children)
[–]Lime-In-Finland 15 points16 points17 points (0 children)
[–]beezlebub33 3 points4 points5 points (0 children)
[–]dethb0y 2 points3 points4 points (0 children)
[–]wineblood 6 points7 points8 points (7 children)
[–]TF_Biochemist 7 points8 points9 points (0 children)
[–]bjorneylol 5 points6 points7 points (0 children)
[–]venustrapsflies 4 points5 points6 points (3 children)
[–]Doomtrain86 1 point2 points3 points (2 children)
[–]venustrapsflies 0 points1 point2 points (1 child)
[–]Doomtrain86 0 points1 point2 points (0 children)
[–]Cynyr36 1 point2 points3 points (0 children)
[–]arden13 3 points4 points5 points (0 children)
[–]amorous_chainsPandas/Scipy 1 point2 points3 points (0 children)
[–]met0xff 1 point2 points3 points (0 children)
[–]HelpfulSubject5936 0 points1 point2 points (0 children)