Help me with the code issue in jupyter

46 views
Skip to first unread message

Vinayak Patankar

unread,
Dec 21, 2016, 8:50:20 AM12/21/16
to Project Jupyter
i am trying to execute this code by ctlr+Enter

import time
import datetime
import matplotlib
import matplotlib.pyplot as plt
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.loadtext('GBPUSD1d.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, colsspan=40)
    
    ax1.plot(date,bid)
    ax1.plot(date,ask)
    
    ax1.xaxis.set_major_formatter(mdates.DataFormatter('%Y-%m-%d %H:%M:%S'))
    
    plt.grid(True)
    plt.show()
   


It doest plot or shows me any error message it just doesnt do anything...can someone help me pls

   
    

Thomas Kluyver

unread,
Dec 21, 2016, 11:40:21 AM12/21/16
to Project Jupyter
Hi Vinayak,

On 21 December 2016 at 13:50, Vinayak Patankar <destinych...@gmail.com> wrote:
def graphRawFX():

Your code defines a function, but it never runs that function. After definining the function, you need to call it:

graphRawFX()

Vinayak Patankar

unread,
Dec 21, 2016, 1:58:36 PM12/21/16
to Project Jupyter
Hi takowl ,
 I Tried that as well but still it doesnt work...i have attached a screenshot to my code..
Screenshot (8).png

Thomas Kluyver

unread,
Dec 21, 2016, 2:40:33 PM12/21/16
to Project Jupyter
You're calling the function inside the function definition. None of the code inside the function runs until you call it, and that includes the call to the function you just added.

In Python, indentation defines what's inside a function (or a loop, or an if block...). So unindent your graphRawFX() call so that it's at the left hand edge of the cell.

--
You received this message because you are subscribed to the Google Groups "Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+unsubscribe@googlegroups.com.
To post to this group, send email to jup...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jupyter/e1a6cdfc-c2ab-4a36-841d-da150a78a008%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Vinayak Patankar

unread,
Dec 22, 2016, 10:19:19 AM12/22/16
to Project Jupyter
Hi takeowl,
i have sent the screenshots..now the output is this...but the graph has not plotted my data its just a empty graph with a error message



On Thursday, De c22, 2016 at 1:10:33 AM UTC+5:30, takowl wrote:
You're calling the function inside the function definition. None of the code inside the function runs until you call it, and that includes the call to the function you just added.

In Python, indentation defines what's inside a function (or a loop, or an if block...). So unindent your graphRawFX() call so that it's at the left hand edge of the cell.
On 21 December 2016 at 18:58, Vinayak Patankar <destinych...@gmail.com> wrote:
Hi takowl ,
 I Tried that as well but still it doesnt work...i have attached a screenshot to my code..

On Wednesday, December 21, 2016 at 10:10:21 PM UTC+5:30, takowl wrote:
Hi Vinayak,

On 21 December 2016 at 13:50, Vinayak Patankar <destinych...@gmail.com> wrote:
def graphRawFX():

Your code defines a function, but it never runs that function. After definining the function, you need to call it:

graphRawFX()

--
You received this message because you are subscribed to the Google Groups "Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+u...@googlegroups.com.

To post to this group, send email to jup...@googlegroups.com.
Screenshot (9).png
Screenshot (10).png

Thomas Kluyver

unread,
Dec 22, 2016, 10:31:37 AM12/22/16
to Project Jupyter
The function you're looking for is called loadtxt, rather than loadtext.

Your issues are not really related to Jupyter. For general issues with Python programming, please ask here:
https://www.reddit.com/r/learnpython/

To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+unsubscribe@googlegroups.com.

To post to this group, send email to jup...@googlegroups.com.

Vinayak Patankar

unread,
Dec 22, 2016, 10:32:34 AM12/22/16
to Project Jupyter
i realised i used np.loadtext instead of np.loadtxt but still i have error :(
Screenshot (11).png
Screenshot (12).png

Vinayak Patankar

unread,
Dec 22, 2016, 1:52:12 PM12/22/16
to Project Jupyter
alright bro
Reply all
Reply to author
Forward
0 new messages