1

I have been using this simple code to plot a .txt file.

import sys
import os
import numpy
from pylab import *

PlanetData = 'planetdata1.txt'

approx_distance_to_sun_(km),approx_velocity_(km/h)= numpy.loadtxt(PlanetData, unpack =True)

plot(approx_distance_to_sun_(km), approx_velocity_(km/h))
xlabel('Distance to sun (Km)')
ylabel('Approx. Velocity (Km/h)')
title('Distance to sun vs. Velocity')
show()

My .txt file is also uploaded here :

#approx_distance_to_sun_(km)     approx_velocity_(km/h)
57909227                         170503                                # Mercury
108209475                        126074                                # Venus
149598262                        107218                                # Earth
227943824                        86677                                 # Mars
778340821                        47002                                 # Jupiter
1426666422                       34701                                 # Saturn
2870658186                       24477                                 # Uranus
4498396441                       19566                                 # Neptune
5906440628                       16809                                 # Pluto <- dwarf planet

Apparently I see no reason to get this error, can anyone help me fix the error?

bhjghjh
  • 889
  • 3
  • 16
  • 42
  • `approx_distance_to_sun_(km)` and `approx_velocity_(km/h)` are function calls, and you cannot assign to function calls. I'm not sure what you were intending to do here. – TigerhawkT3 Sep 15 '16 at 02:55
  • 1
    Python names cannot include the characters `(` and `)`. Python thinks `approx_distance_to_sun_(km)` is a call of the function `approx_distance_to_sun_` with argument `km`. You could change those names to, say, `approx_distance_to_sun_km ` and `approx_velocity_kmph`. – Warren Weckesser Sep 15 '16 at 02:55
  • oh now I see, worked nice just after changing the headings. thanks – bhjghjh Sep 15 '16 at 02:59

0 Answers0