Python Forum
plotting data without plt.clear()
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
plotting data without plt.clear()
#1
I am trying to use a matplotlib module in order to draw data coming from notepad the problem is that I must clear the data every time I parse data in order to plot the data by using plt.clear() now I want to have other alternatives as when I want to zoom in for the graph it returns automatically to the previous plotting which is annoying. The following is considered as a sample of the code
f = Figure(figsize=(5,5), dpi=100)
a = f.add_subplot(111)


def animate(i):
    pullData = open("sampleText.txt","r").read()
    dataList = pullData.split('\n')
    xList = []
    yList = []
    line,=plt.plot([],[])
    for eachLine in dataList:
        if len(eachLine) > 1:
            x, y = eachLine.split(',')
            xList.append(int(x))
            yList.append(int(y))
            line.set_data(xList,yList)
             
   

    a.clear()##the part that I want to have an alternative code for it
    a.plot(xList, yList)
Thanks for any help
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [Solved] Plotting data from txt file Laplace12 1 1,819 Jul-06-2021, 07:14 AM
Last Post: Laplace12
  Plotting sum of data files using simple code Laplace12 3 3,051 Jun-16-2021, 02:06 PM
Last Post: BashBedlam
  Plotting 3D Data with Custom Colorbar Gates666 0 1,696 Jul-09-2020, 10:56 AM
Last Post: Gates666
  Python animate live plotting fetching data from Mysql Table dhirajm 6 3,644 Apr-24-2020, 05:07 PM
Last Post: dhirajm
  plotting 2 different set of data in a single plot with shared axes. upasana 4 3,680 Mar-21-2018, 01:43 PM
Last Post: upasana

Forum Jump:

User Panel Messages

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