1

Optimizing PyQt5 and Matplotlib canvas redrawing for real-time data processing, was originally closed as Needs more focus, deleted by the OP, opened as a new, subsequently deleted question, migrated back to the original post, and reopened.

The question is, should this question remain closed?

My original, now deleted comment, was something like:

My scripts does the job, but I wanna increase the speed of it. Please review What topics can I ask about here? & Don't advise on off-topic questions. The question is asking for opinions, and lacks focus.

The reasoning was, the issues raised in the question can't be reproduced because this is regarding a GUI for real time data processing, using a webcam, and only provides:

class Canvas(FigureCanvas):
    def __init__(self, parent=None):
        fig, (self.ax1, self.ax2) = plt.subplots(2, sharex= True, sharey= False, figsize=(10, 10))
        super(Canvas, self).__init__(fig)

and part of the while cycle

self.canvas.ax1.cla()
self.canvas.ax2.cla()
self.canvas.ax1.plot(self.dn, self.dx, label = 'X tengely', linewidth = 1, color='#66ff33')
self.canvas.ax2.plot(self.dn, self.dy, label = 'Y tengely', linewidth = 1, color='#ff5050')
self.canvas.ax1.legend('X')
self.canvas.ax2.legend('Y')
self.canvas.ax1.set_xlim(i - 50, i)
self.canvas.ax2.set_xlim(i - 50, i)
self.canvas.draw()

The question does include examples of attempted fixes. However, since there is not enough code, and required hardware, for contributors to actually run, the question doesn't have enough focus, needs debugging details, and seeks opinions.

Is it okay to ask for code optimization help? suggests information, such as profiling, to also include in the question.

The assertion about opinions is because a question that can't be reproduced, is likely to result in answers with opinions, and guessing.

As proof of the point, this posted answer, offers opinions like Essentially, matplotlib's architecture is not suitable for what you're trying to do, and suggests an alternate package. Nothing concrete for the OP. Incidentally, questions Seeking recommendations for books, tools, software libraries, and more should be closed.

The assertion about focus is because there isn't enough focus on the specific detail of the slowdown, which could be informed by profiling output, and because the metric is ambiguous:

I would like to make a faster solution, because now the canvas.draw() method seems a little slow for me,...

Clear Question & Complete Minimal Reproducible Code

How do you real-time plot a colormap? was just posted (2023-06-06 19:18:26) by a new, low rep user, and is an excellent example of a clear question, with a complete, executable, minimal reproducible example for QT and real-time visualizations.

I was able to copy the code as posted, and run it in PyCharm.

5
  • 6
    In my humble opinion, the question should have remained closed. I noticed the repost, but I was at work and didn't have time to flag it in time, otherwise the "new" one would have been probably closed sooner. The OP clearly didn't understood the reason of the closure and didn't make any effort in providing further information, data, statistics or whatsoever, so the original problem remains: it's open ended, leads to opinion based answers, and is completely based on a unique use case that would hardly help anyone else. Commented Jun 5, 2023 at 6:05
  • shouldnt be better to find a way to have OP posting an MRE, the topic is of interest for me, but I am not good enough to proposed an MRE. Like giving OP the time for producing an MRE othewise than close it ?
    – pippo1980
    Commented Jun 5, 2023 at 19:32
  • I do like the fact that you asked this question here, @Trenton! I'd like to point out that taking the singular question sentence, even visibly abbreviated by ellipses, might be framing the original question as if there was no investigative work done by that asker: I do think that's not the case (and I don't think you disagree on them having done some comparison with at least two other things they show); I hence don't agree on the focus lacking: The question describes a clear problem. Commented Jun 5, 2023 at 21:46
  • Stackoverflow made a blog post some time ago about how they want to improve the community. But this post makes me wonder, why is the question if the users question should be closed? Why is it not "How can we help the user to improve the question?" since the user clearly did not understand why the question was closed in the first place. It should be communicated better what the user did wrong.
    – RaZor1994
    Commented Jun 6, 2023 at 12:57
  • 1
    @RaZor1994 Just how much handholding are we supposed to provide? In the blue Closed box is a linked reason for the closure. There are links in comments to the OP. As noted, this question was closed once to Needs more focus. The OP deleted the question, and reposed it without any changes. This question has been closed twice, with no substantial changes. It is the responsibility of the OP to follow the substantial guidelines and tutorials provided already provided by the community, and we have no ability to force any individual to follow through. Commented Jun 6, 2023 at 14:04

2 Answers 2

11

Yes, it currently lacks information about a specific problem that can be answered objectively.

If you have working code and want to see how it can be improved in an open-ended way, you should consider the Code Review sister site.

For Stack Overflow, this question needs edits to specify exactly what qualifies as an acceptable redrawing speed; just saying "I want to optimize this" is too vague.

7
  • 2
    Hi! "method seems a little slow for me" is clearly asking for anything faster, there is no need to to go to the head of OP and looking for something more than what the words mean :)
    – gss
    Commented Jun 6, 2023 at 12:12
  • @gss OK. How fast is faster? Did OP mention why the speed 100ms was not fast enough? Was the 100ms speed consistent between multiple runs? Did they mention their compiler settings? Their hardware and software? What is an acceptable performance increase? Why is that an acceptable performance increase?
    – TylerH
    Commented Jun 6, 2023 at 13:42
  • 2
    Who cares? They want it to run faster. They showed us the code that they're currently running. We don't need to know why. Any answer that improves the performance and/or explains why it is not possible to improve the performance is a valid answer.
    – Cody Gray Mod
    Commented Jun 6, 2023 at 14:09
  • 1
    @CodyGray-onstrike Whoever wants to know or provide the answer cares.
    – TylerH
    Commented Jun 6, 2023 at 19:32
  • 2
    I've answered a lot of optimization questions; I almost never want to know these things. So, again, citation needed. This just seems like arbitrary, unproductive gatekeeping, restricting optimization questions to the point where you're turning them into "debug my code" questions, which are the least useful and least interesting questions that we have on SO.
    – Cody Gray Mod
    Commented Jun 6, 2023 at 21:49
  • @CodyGray-onstrike I disagree with your point 100%. I'm an engineer, and when someone requires it needs to be faster, there must be a quantifiable metric, otherwise it's just a bunch of handwaving. I'm guessing, if I had the full code from the OP, it would run faster, given my hardware. As such, I've answered the question, just by running it on better hardware, and their issue is not reproducible. Putting that aside, the question still lacks a complete minimal reproducible example, making the current closed reason valid. Commented Jun 7, 2023 at 4:45
  • I have a question on Stack Overflow about performance when I said only that I need something faster than my code and no one closed this question, I have also received very valuable two answers :). But maybe it should be closed now?
    – gss
    Commented Jun 7, 2023 at 11:06
-5

As you can imagine, I don't think it should be closed – I'm the one with the mediocre answer.

The poster doesn't ask

I have this complex problem, someone optimize it for me!

They instead ask:

I have quantified that this specific step in my program logic takes longer than I accept. I've tried myself – see these two approaches, one of which was as slow, the other didn't work – and I'm out of my depth on how to improve further.

So, that's a high-effort question with a clear objective and a wide potential future audience.

I don't understand why this would be closed – there's not really any information lacking to understand the problem, it's highly specific, it's not low-effort, it's about programming, and it's not about opinions.

Is it okay to ask for code optimization help? suggests information, such as profiling, to also include in the question.

And that information is there.

The meta q&a being cited as reason to be closed is being interpreted in an overly narrow way, and that by high-rep users: the spirit of the Meta Answer is clear in that questions that are super wide, show little attempt to increase the performance of something and have done no actual profiling, well close away. But only seeing "there's no profiling in there", and deducting the question should be closed is bogus.

Remember this site is still actually about helping people, not about finding a way to sue askers or answerers.

10
  • And remember that potential answerers are just as deserving of help as askers. If people ask for clarification, further information, sample data, etc in comments, it's rude and unhelpful for the asker to ignore all that and then later repost exactly the same question. Community Q & A is all about give and take.
    – ekhumoro
    Commented Jun 5, 2023 at 9:52
  • 3
    "Remember this site is still actually about helping people" I disagree. I think that Stack Overflow, like any other knowledge base, exists so people can help themselves, if at all possible by searching for existing answers because otherwise what's the darned point of building a knowledge base. You try to use it as a helpdesk and you will eventually run into trouble because you'll be breaking harsh quality rules that prohibit such usage.
    – Gimby
    Commented Jun 5, 2023 at 12:21
  • 2
    @Gimby That is a very depressing view, which I will not entertain! It is about people helping people. Yes, there's a give and take. But that's to an end: People helping people. Commented Jun 5, 2023 at 12:24
  • 6
    You wrongly associate the asker's effort with whether the question can be answered in a practical way. If the OP desirers faster code, there must be sufficient code supplied to run, there is not, there must be an objective, achievable goal, this is not, which are sufficient reasons to close the question. As a matplotlib subject matter expert, who has spent thousands of hours answering matplotlib questions, and often spends more than an hour on any single question, my informed opinion is the question cannot be answered in a practical way, or a way that's beneficial to the community. Commented Jun 5, 2023 at 12:33
  • 2
    Further, the OP doesn't deserve anything. The OP is asking contributors to spend their valuable time answer a question with insufficient code to reproduce the issue. It lacks a complete minimal reproducible example, and no other reason is required for closure. And you did not supply a mediocre answer, you suppled a comment, which you posted as an answer. Commented Jun 5, 2023 at 12:37
  • 1
    Nope, it's an answer. If you have a problem with the quality my answer, please downvote it. Let's not open that discussion here, it distracts from the question about the question. By the way, I can paste his code into a minimal jupyter notebook and use it as an update function, maybe you're not competent at assessing what a minimal example is in this case! Commented Jun 5, 2023 at 14:47
  • @MarcusMüller Hi the sytem flagged your answer as Low quality answers , ended up giving the Looks OK when encountered in the Low quality answers queue, at the end the quality of the answer here depends on the qulity of the question as I understood
    – pippo1980
    Commented Jun 5, 2023 at 21:20
  • "So, that's a high-effort question with a clear objective and a wide potential future audience." What is the clear objective? All I see is "I want it faster" but they don't mention how fast is acceptable. 100ms seems plenty fast to me, so by my calculations the question isn't in need of an answer as OP already has it in their own code.
    – TylerH
    Commented Jun 6, 2023 at 13:43
  • @TylerHb, "So, that's a high-effort question with a clear objective and a wide potential future audience." no of course not but Muller answer was at his best given the question
    – pippo1980
    Commented Jun 6, 2023 at 15:11
  • 1
    "It is about people helping people." - No; as explained in the tour, it is about "build[ing] a library of detailed, high-quality answers". "Helping people" is only relevant insofar as the existence of that library is helpful. Commented Jun 9, 2023 at 4:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .