Python Forum
How to continue code after .show() in matplotlib?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to continue code after .show() in matplotlib?
#1
How can i continue my code thats written after .show() in the matplotlib library?
There needs to come an input from the user after the plot shown based of what the user sees in the plot, but i cant get my code to continue to run untill only after you have closed the plot's window by hand. Is there a way to keep it running?
Reply
#2
You can use threading. Divide your code into plot part and other part.
from matplotlib import pyplot as plt
import threading

def yourFunc():
    result = input("your input: ")
    print(result)

def plot():
    x, y = [0, 1], [0, 1]
    plt.plot(x, y)
    plt.show()

def main():
    mthread = threading.Thread(target=yourFunc)
    mthread.start()
    plot()
    mthread.join()

main()
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [split] How to continue code after .show() in matplotlib? pythonnewbie62 1 405 Apr-28-2025, 04:02 PM
Last Post: deanhystad
  PIL Image im.show() no show! Pedroski55 2 4,831 Sep-12-2022, 10:19 PM
Last Post: Pedroski55
  List Creation and Position of Continue Statement In Regular Expression Code new_coder_231013 3 2,833 Jun-15-2022, 12:00 PM
Last Post: new_coder_231013
  PIL Image im.show() no show! Pedroski55 6 19,005 Feb-08-2022, 06:32 AM
Last Post: Pedroski55
  Matplotlib: How do I convert Dates from Excel to use in Matplotlib JaneTan 1 4,400 Mar-11-2021, 10:52 AM
Last Post: buran
  matplotlib.pyplot.show Alienspecimen 2 4,917 Feb-27-2021, 02:32 AM
Last Post: snippsat
  Line of code to show dictionary doesn't work MaartenRo 2 3,289 Jul-28-2020, 03:58 PM
Last Post: deanhystad
  Show graphs in matplotlib from a sql query? ScaleMan 1 2,539 Feb-06-2020, 05:47 PM
Last Post: ScaleMan
  Press a botton to continue the code doug2019 1 2,573 Nov-18-2019, 09:38 AM
Last Post: Gribouillis
  error using 'continue' in my code ilcaa72 1 2,648 Jun-05-2019, 08:05 PM
Last Post: vindo

Forum Jump:

User Panel Messages

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