Created
March 22, 2023 06:30
-
-
Save surajRathi/4350bfde1940bf5759cbb09e95445873 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /usr/bin/python3 | |
| from time import sleep | |
| import matplotlib.pyplot as plt | |
| import numpy as np | |
| from matplotlib.axes import Axes | |
| from matplotlib.figure import Figure | |
| from matplotlib.lines import Line2D | |
| def main(): | |
| f: Figure | |
| ax: Axes | |
| f, ax = plt.subplots() | |
| x = np.linspace(0, 10, 10) | |
| y = 0 * x | |
| pdata = ax.plot(x, y) | |
| line: Line2D = pdata[0] | |
| plt.pause(0.01) | |
| ax.set_xlim(0, 10) | |
| ax.set_ylim(0, 10 * 10) | |
| for m in range(10): | |
| print(f"Slope: {m}") | |
| line.set_ydata(m * x) | |
| f.canvas.draw() | |
| f.canvas.flush_events() | |
| plt.pause(0.01) # For letting us click and zoom on plot | |
| sleep(1) | |
| if __name__ == '__main__': | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment