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
  PIL Image im.show() no show! Pedroski55 2 927 Sep-12-2022, 10:19 PM
Last Post: Pedroski55
  List Creation and Position of Continue Statement In Regular Expression Code new_coder_231013 3 1,602 Jun-15-2022, 12:00 PM
Last Post: new_coder_231013
  PIL Image im.show() no show! Pedroski55 6 4,739 Feb-08-2022, 06:32 AM
Last Post: Pedroski55
  Matplotlib: How do I convert Dates from Excel to use in Matplotlib JaneTan 1 3,162 Mar-11-2021, 10:52 AM
Last Post: buran
  matplotlib.pyplot.show Alienspecimen 2 2,191 Feb-27-2021, 02:32 AM
Last Post: snippsat
  Line of code to show dictionary doesn't work MaartenRo 2 2,397 Jul-28-2020, 03:58 PM
Last Post: deanhystad
  Show graphs in matplotlib from a sql query? ScaleMan 1 1,817 Feb-06-2020, 05:47 PM
Last Post: ScaleMan
  Press a botton to continue the code doug2019 1 1,828 Nov-18-2019, 09:38 AM
Last Post: Gribouillis
  error using 'continue' in my code ilcaa72 1 2,025 Jun-05-2019, 08:05 PM
Last Post: vindo
  show grayscale image using matplotlib zyb1003 1 16,487 Nov-01-2017, 11:45 AM
Last Post: heiner55

Forum Jump:

User Panel Messages

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