0

I have two issues with my python plot that would be grateful if anyone could help me with:

1- I wonder if it is possible in python to have the option for the plots after display to add horizontal or vertical lines, so that these new lines could be added, moved or deleted without the need to run the code again.

to say it more clearly, I am looking for additional features that adding them does not need to change the code and they only enable me to manually draw on the already plotted image.

2- I want to plot a very large image in the real size, So that I need to add the horizontal and vertical slide bars to be able to scroll up/down or left/right in the plot?

I need to combine these two ability for my project, can someone help me with that?

1 Answers1

0

1- You can't physically draw on it, but you can make a plot in matplotlib interactive as follows:

import matplotlib.pyplot as plt


plt.ion()                                       # turns on interactive mode
fig = plt.figure()
ax = fig.add_subplot()
plt.ylim(-10, 10)
plt.xlim(0, 10)

while True:
    plt.axhline(float(input("number")))
    fig.canvas.draw()
    fig.canvas.flush_events()                   # draws

This program allows you to create horizontal lines based on user input.

I think you can solve 2 with tkinter, but that would be pretty difficult. There might also an easier way. See this stack overflow question for an example of an interactive plot in tkinter. I believe this plot can be made bigger and scrollable, but I am not sure.

Rik Mulder
  • 245
  • 1
  • 9