Python Forum
Dynamic graph matplotlib
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dynamic graph matplotlib
#1
I draw a lot of data in matplotlib. So I want to make a widget that adjusts the scale horizontally with automatic adjustment vertically.
And after adjusting the zoom use the scroll bar to view the entire graph. Is it possible to do this in matplotlib?
C# is much more complicated than Python, but I was able to do it with it. But in Python I can not do it, I have to study several libraries(Tkinter, PyQt, matplotlib). And it is not clear whether I'm on the right path?
Asked questions on "stackoverflow" and received nothing intelligible as the answer.


from tkinter import *
from matplotlib.backends.backend_tkagg import (
    FigureCanvasTkAgg, NavigationToolbar2Tk)
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np

x = pd.read_csv('file.txt',index_col='DATE',parse_dates=True,infer_datetime_format=True)
z = x.iloc[:, 3].values
N = len(z)
ind = np.arange(N)
fig, ax = plt.subplots()
ax.plot(ind, z)

root = Tk()
canvas = FigureCanvasTkAgg(fig, master=root)
canvas.get_tk_widget().pack(side=tkinter.TOP, fill=tkinter.BOTH, expand=1)
canvas.show()

toolbar = NavigationToolbar2Tk(canvas, root)
toolbar.update()

scrollbar = tkinter.Scrollbar(master=root, orient=HORIZONTAL)
scrollbar.pack(fill=X)

scrollbar["command"] = canvas.get_tk_widget().xview

tkinter.mainloop()

And it's not the first time I come across in Python that no one knows the answer)

If you need something non-standard, then in Python it is difficult to do....
Reply
#2
I was able to program the Slider as in the link.Slider
I posted a GIF how it turned out [Image: 7g80wZg]
But still want to do so in tkinter.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] Tkinter Matplotlib Animation Graph not rendering dimidgen 3 340 Mar-12-2024, 02:09 PM
Last Post: deanhystad
  [Tkinter] cutomtkinter matplotlib no x,y - xaxis and x,y - labels-> only graph and grid visible dduric 0 236 Feb-20-2024, 07:09 PM
Last Post: dduric
  How to show graph as a slideshow in PyQt5 using matplotlib binsha 0 3,878 Mar-08-2019, 03:58 AM
Last Post: binsha

Forum Jump:

User Panel Messages

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