How to plot graph x,y for text file
27 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Yasumin Mingmuang
il 29 Set 2018
Modificato: Walter Roberson
il 30 Set 2018
Hi! I want to plot graph but I don't read file from file txt.
This is my code.
import matplotlib.pyplot as plt
import numpy as np
with open('t.txt','r',encoding = 'utf8') as f:
data = f.read()
data = data.split('\n')
x = [float(raw.split()[0]) for raw in data]
y = [float(raw.split()[1]) for raw in data]
plt.plot(x,y,'ro')
plt.show()
And my data in text file, t.txt.
Please help me
Thankyou
1 Commento
Risposta accettata
ANKUR KUMAR
il 29 Set 2018
A=load('test.txt');
plot(A(:,1),A(:,2))
2 Commenti
ANKUR KUMAR
il 30 Set 2018
I didn't get you. Do you want me to run the code and give the figure.
Well, I am attaching the matlab figure, so that you can edit too from your matlab command window.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Call Python from MATLAB in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!