Python Forum
Use of IdnexData on datafile
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Use of IdnexData on datafile
#1
The following snippet of code I want to use to create a plot.

plt.figure(figsize(20, 8))
plt.plot(IndexData['sensor_01'], labels='sensor_01')
plt.plot(IndexData['machine_stautus'], labels='machine_status')
plt.xlabel('Index')
plt.legend()
plt.show()
Now everything is defined except IndexData, which is not defined. I have used index very little in my Python programming. I assume IndexData is simply an integer variable for a for loop. I have 220320 data points for machine_status and sensor_01 data, each. I am guessing this just a for loop that runs through all of those 220320 points. It seems that this is an awkward way to do this I remember other data plots that used much simpler python code.

The graph that I am trying to plot looks like the attached figure. Any help appreciated. Even a link would help I just have not used index before, and I am somewhat confused how to use it

Respectfully,

LZ
The following code:

plt.figure(figsize(20, 8))
plt.plot(IndexData['sensor_01'], labels='sensor_01')
plt.plot(IndexData['machine_stautus'], labels='machine_status')
plt.xlabel('Index')
plt.legend()
plt.show()
gives the following error:

Output:
NameError Traceback (most recent call last) Input In [48], in <cell line: 5>() 1 # Plotting sensor_01, machine_status_data 2 # X-label shows Index 4 plt.figure(figsize(20, 8)) ----> 5 plt.plot(IndexData['sensor_01'], labels='sensor_01') 6 plt.plot(IndexData['machine_stautus'], labels='machine_status') 7 plt.xlabel('Index') NameError: name 'IndexData' is not defined <Figure size 1440x576 with 0 Axes>
Okay IndexData is not defined. It is obviously an index. Now the data that I want to plot can be shown with two graph attachments. I must post two because the data is so long with 52 sensors. Thus, I must post two attachments.
Sorry I Have to put my final writing the question on another reply. The software would not let me add it to the second post.

Okay IndexData is not defined. It is obviously an index. Now the data that I want to plot can be shown with two graph attachments. I must post two because the data is so long with 52 sensors. Thus, I must post two attachments to show all of it.

Now my question is as anyone can see the extreme left-hand columns are numeric starting at 1 and going down to the last data point which is 220320.

So, if IndexData is no defined how do I connect it up with this extreme left column? The must be a way. Afterall, I can read the data in a for loop for each of the 50+ sensors.

So, the solution I beleive is to attach (somehow) IndexData to one of those leftmost columns. Each number (in the left most columns) represents a one-minute time unit. That is perfect.

How to connect IndexData to the column?

Any help appreciated. Even a link would help. I just do not know how to do this.

Thanks in advance.

LZ

Attached Files

Thumbnail(s)
           
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  myfile = open(datafile, 'rb') not working mford29_programmer 4 2,952 Oct-10-2019, 10:49 AM
Last Post: mford29_programmer
  Last Line of datafile not loading salehin 1 2,729 Aug-21-2017, 06:05 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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