Python Forum
How to instantly update the plot by getting values from a Scale widget?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to instantly update the plot by getting values from a Scale widget?
#20
Quote:I didn't understand what is the usage of set_array(x,y)
In the animation demo, and my subsequent reuse of that code, set_array(x, y) changes the data displayed in the plot.

This code change the values stored in the QuadMesh object self.mesh.
self.mesh.set_array(self.data[:-1, :-1, level].flatten())
When the plot is redrawn, it displays the new values.
self.figure.canvas.draw()
Your code does something different. Your code creates a new QuadMesh object.
ax.pcolormesh(x, y, layer, cmap=newcmp, edgecolor='lightgrey', linewidth=0.003)
This not only changes the data in the QuadMesh object (actually creates a new QuadMesh object), but it reconfigures the plot. The new plot might have different range. The labels might change.

The result is not much different. You see a plot of the new data. But your code is doing a lot more work then mine. This isn't really noticeable for your application, but it would be very noticeable if you had the plot changing several times a second. If I wanted to make a plot of real-time values, like an oscilloscope, I would not be pleased with the extra delay introduced by reconfiguring the entire plot each time I just added some now signal points.
Reply


Messages In This Thread
RE: How to instantly update the plot by getting values from a Scale widget? - by deanhystad - May-17-2022, 03:52 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Update exist plot while change upper limit or lower limit SamLiu 1 1,003 Feb-05-2023, 10:09 AM
Last Post: SamLiu
Exclamation Update Point Coordinates from Mouse Event in a Plot Jguillerm 2 1,322 Jan-10-2023, 07:53 AM
Last Post: Jguillerm
  [Tkinter] Update matplotlib plot correctly Particledust 0 4,672 Apr-20-2020, 04:59 PM
Last Post: Particledust
  [Tkinter] Scale at the Top Friend 5 2,886 Jul-20-2019, 05:02 PM
Last Post: Yoriz
  Update plot by <Return> bind with entry widget Zorro 1 4,178 Mar-09-2019, 12:27 PM
Last Post: Zorro
  [Tkinter] update the content of Text widget atlass218 10 16,274 Dec-15-2018, 11:51 AM
Last Post: atlass218
  [Tkinter] Update value in Entry widget dannyH 7 27,737 Apr-02-2017, 10:12 AM
Last Post: dannyH
  [Tkinter] Resetting scale value back to 0 after the slider loses focus lwhistler 3 7,020 Mar-07-2017, 10:01 PM
Last Post: Larz60+
  Bokeh - dynamic update widget.Select values sixteenornumber 0 10,305 Dec-28-2016, 02:15 PM
Last Post: sixteenornumber

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020