Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 connecting the first point to the last point Matplotlib
I wanted to plot by using matplotlib library to plot data frames that read from database SQL without using plt.pause so I created a class to plot and animate the data but the problem is the last point is connected to the first point by a line
class RealtimePlot:
    def __init__(self, axes, max_entries = 100):
        self.axis_x = deque(maxlen=max_entries)
        self.axis_y = deque(maxlen=max_entries)
        self.axes = axes
        self.max_entries = max_entries
        self.lineplot, = axes.plot([], [], "ro-")

    def add(self, x, y):
        self.lineplot.set_data(self.axis_x, self.axis_y)
        self.axes.set_xlim(self.axis_x[0], self.axis_x[-1] + 1e-15)
        self.axes.relim(); self.axes.autoscale_view() # rescale the y-axis

    def animate(self, figure, callback, interval = 50):
        import matplotlib.animation as animation
        def wrapper(frame_index):
            self.axes.relim(); self.axes.autoscale_view() # rescale the y-axis
            return self.lineplot
        animation.FuncAnimation(figure, wrapper, interval=interval)

The workaround that I tried to sort the data as I searched on StackOverflow and other websites also I didn't solve the problem any help would be appreciated if the whole code is required I would post it.

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  floating point not increasing properly rakeshpe43 4 255 Apr-30-2020, 05:37 AM
Last Post: rakeshpe43
  Song Modifying Program Starting Point BadenJaden 1 302 Mar-27-2020, 11:36 AM
Last Post: pyzyx3qwerty
  Covert Shapely Point() to (x, y) michael1789 0 118 Mar-26-2020, 12:33 AM
Last Post: michael1789
  floating point arithmetic exDeveloper 2 282 Sep-25-2019, 04:33 PM
Last Post: DeaD_EyE
  finding the closest floating point number in a list Skaperen 17 1,097 Sep-19-2019, 10:39 PM
Last Post: Skaperen
  finding the next higher representable floating point value Skaperen 0 485 Sep-13-2019, 11:16 PM
Last Post: Skaperen
  Creating a Point from coordinate fields in shapefile stixmagiggins 0 231 Aug-28-2019, 06:33 AM
Last Post: stixmagiggins
  Finding nearest point of a Multidigraph in Python 3.7 stixmagiggins 5 663 Aug-24-2019, 08:51 AM
Last Post: ThomasL
  Pygal: Displaying information for each data point KirkmanJ 0 324 Jul-29-2019, 01:10 PM
Last Post: KirkmanJ
  Practicing using a "flag": please point in right direction magsloo 5 540 May-10-2019, 04:58 AM
Last Post: perfringo

Forum Jump:

Users browsing this thread: 1 Guest(s)