Python Forum
URGENT: How to plot data from text file. Trying to recreate plots from MATLAB
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
URGENT: How to plot data from text file. Trying to recreate plots from MATLAB
#1
Exclamation 
I have the following data saved from a MATLAB code and they have the following form:
Quote:0,0.001,0.002,0.003,0.004,0.005,0.006,0.007,0.008,0.009,0.01,0.011,0.012,0.013,0.014,0.015,0.016,0.017,0.018,..
and I am trying to recreate my plot from MATLAB that looks like:
matlabplot


So I have written the following python code that is not working:
XX, YY =[], []
for line in open('RhoMacCormack_sigpt05_cflpt5.txt','r'):
    values = [float(s) for s in line.split()]
    XX.append(values[0])
    YY.append(values[1])
    plt.plot(XX,YY)
    plt.show()
Gives the error:
ValueError: could not convert string to float: '0,0.001,0.002,0.003,0.004...
Could someone help me get this working?
Reply


Messages In This Thread
URGENT: How to plot data from text file. Trying to recreate plots from MATLAB - by JamieAl - May-08-2021, 07:00 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Fit straight line to pandas time series data with semilog plot schniefen 2 1,557 Mar-10-2023, 01:08 PM
Last Post: jefsummers
  Plot time series data schniefen 3 1,350 Mar-04-2023, 04:22 PM
Last Post: noisefloor
Exclamation Python Homework (Urgent help needed!!) chickenseizuresalad 6 4,331 Oct-11-2021, 01:59 AM
Last Post: Underscore
Exclamation urgent , Python homework alm 2 2,332 May-09-2021, 11:19 AM
Last Post: Yoriz
  urgent I got a syntax errors alm 2 5,898 Feb-28-2021, 02:54 PM
Last Post: alm
Heart Urgent homework help needed Medou 4 2,761 Nov-24-2020, 09:28 AM
Last Post: buran
  Working with text data APK 4 2,515 Aug-22-2020, 04:48 AM
Last Post: buran
  [Urgent] build code GodMaster 2 1,822 Mar-23-2020, 12:25 AM
Last Post: jefsummers
  Bifid Genkey (Urgent) Laura123 2 2,063 Mar-09-2020, 08:09 PM
Last Post: micseydel
  Read text file, process data and print specific output Happythankyoumoreplease 3 2,932 Feb-20-2020, 12:19 PM
Last Post: jefsummers

Forum Jump:

User Panel Messages

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