Python Forum
Graphic line plot with matplotlib, text file in pytho
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Graphic line plot with matplotlib, text file in pytho
#1
hello, I want to display a graph using data from a text file with matplotlib and I am having some problems. Data is sent and received via sockets and stored in a text file.

here is my code:
import matplotlib.pyplot as plt



X = []
Y = []




fichier = open('orde.txt', 'r')


for row in fichier:
    row=row.split(' ')
    if len(row)>0:
     X.append(row[0])
     Y.append(row[-1])



plt.xlabel('Time' , fontsize = 12)
plt.ylabel('Amplitude', fontsize = 12)
plt.plot(X, Y ,color = 'red', label = 'signal')

plt.title('Courbe', fontsize = 20)
plt.show()
Larz60+ write Aug-12-2022, 05:24 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use bbcode tags on future posts.
Reply


Messages In This Thread
Graphic line plot with matplotlib, text file in pytho - by khadija - Aug-12-2022, 01:43 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  matplotlib x-axis text move bottom upward jacklee26 3 1,052 May-31-2023, 04:28 AM
Last Post: jacklee26
  File "<string>", line 19, in <module> error is related to what? Frankduc 9 12,699 Mar-09-2023, 07:22 AM
Last Post: LocklearSusan
  Getting last line of each line occurrence in a file tester_V 1 904 Jan-31-2023, 09:29 PM
Last Post: deanhystad
  How to read csv file update matplotlib column chart regularly SamLiu 2 1,109 Jan-21-2023, 11:33 PM
Last Post: SamLiu
Thumbs Up Need to compare the Excel file name with a directory text file. veeran1991 1 1,166 Dec-15-2022, 04:32 PM
Last Post: Larz60+
  Trying to loop through code to plot seaborn line plots across multiple subplots eyavuz21 0 1,725 Dec-05-2022, 10:46 AM
Last Post: eyavuz21
  Writing string to file results in one character per line RB76SFJPsJJDu3bMnwYM 4 1,422 Sep-27-2022, 01:38 PM
Last Post: buran
  Modify values in XML file by data from text file (without parsing) Paqqno 2 1,746 Apr-13-2022, 06:02 AM
Last Post: Paqqno
  Skipping line in text without Restarting Loop IdMineThat 4 1,538 Apr-05-2022, 04:23 AM
Last Post: deanhystad
  Print to a New Line when Appending File DaveG 0 1,246 Mar-30-2022, 04:14 AM
Last Post: DaveG

Forum Jump:

User Panel Messages

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