Python Forum
Can I include text using artist?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can I include text using artist?
#1
I am trying to update a plot as fast as possible. The quickest way I found so far is in this post, where a line plot updates very quickly using a while loop. This is the code that updates a line amazingly fast:
import time
import numpy as np
import matplotlib.pyplot as plt

fig, ax = plt.subplots()
line, = ax.plot(np.random.randn(100))

fig.canvas.draw()
plt.show(block=False)


tstart = time.time()
num_plots = 0
while time.time()-tstart < 5:
    line.set_ydata(np.random.randn(100))
    ax.draw_artist(ax.patch)
    ax.draw_artist(line)
    fig.canvas.blit(ax.bbox)
    fig.canvas.flush_events()
    num_plots += 1



Now I want to include text (which updates as quickly as the lines) in the plot (it can be within the plot area, eg like a legend) or as the title of the plot, both would be fine. I tried different ways but it doesn't work (text is updated only when the loop ended).

Is there a way to update text as quickly as line? (as mentioned, updating a set.text or alike within the while loop does not work)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to include one script into another? MorningWave 8 305 Mar-21-2024, 10:34 PM
Last Post: MorningWave
  how include a python code in notpad++ plugin akbarza 2 580 Sep-25-2023, 08:25 PM
Last Post: deanhystad
  Regex Include and Exclude patterns in Same Expression starzar 2 736 May-23-2023, 09:12 AM
Last Post: Gribouillis
  How to include input as part of variable name Mark17 4 2,444 Oct-01-2021, 06:45 PM
Last Post: Mark17
  How to include pandas with pyinstaller Rickus 1 10,428 Feb-19-2020, 08:01 PM
Last Post: snippsat
  How to include Variable in File Path penahuse 3 7,220 Jan-05-2020, 03:08 AM
Last Post: ichabod801
  Cannot open include file: 'ft2build.h' thracian 0 4,769 Nov-11-2019, 09:08 PM
Last Post: thracian
  random selection of song and artist not working Unknown_Relic 2 2,317 Nov-08-2019, 02:06 PM
Last Post: perfringo
  I need a query to select the numbers that include 2 digits of 3 omidvakili 1 1,611 Sep-20-2019, 03:49 PM
Last Post: Yoriz
  Trying to include an If statement in my While Loop junkankit 3 2,913 Jan-31-2019, 10:06 AM
Last Post: buran

Forum Jump:

User Panel Messages

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