2

My python version is: Python 2.7 (r27:82525, Jul 4 2010, 07:43:08) [MSC v.1500 64 bit (AMD64)] on win32

I'm getting a message called "Syntax Error| There's an error in your program: invalid syntax"

The 7 in Python 2.7 is highlighted red.

My code is:

Python 2.7 (r27:82525, Jul  4 2010, 07:43:08) [MSC v.1500 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
import matplotlib
import matplotlib.pyplot as plt
import matplotlib.ticker as mticker
import matplotlib.dates as mdates
import numpy as np

def graphRawFX () :
date,bid,ask = np.loadtxt('GPBUSD1d.txt'), unpack=True,
                          delimiter=',',
                          converters={0:mdates.strpdate2num('%Y%m%d%H%M%S') }
fig = plt.figure(figsize=(10,7))
ax1 = plt.subplot2grid((40,40), (0,0), rowspan=40, colspan=40)

ax1.plot(date,bid)
ax1.plot(date,ask)

ax1.xaxis.set_major_formatter(mdates.DateFormatter('%Y-%m-%d %H:%M:%S'))

1 Answer 1

2

The first two lines are not Python code; they are just introductory text when you start the interpreter. Remove them from the script, as it appears you copy-and-pasted too much from an example. Once you've done that, you'll also need to fix your indentation, as at least one of the lines following the def graphRawFX() line needs to be indented.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, could you tell me how to indent? Any links at all would be definitely helpful.
@user1566769: see this link, look at the example then go down to the third point. Indenting works the same for function definitions (using def).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.