python - plt.figure() with title gives error: invalid literal for int() with base 10 -


i have problem when running following simple example code on python 2.6.5. have looked other solutions invalid literal problems , seems me occurs when python assumes data plotting integers , tries iterate on data. error seems reached before point, when figure object created. may wrong , appreciate pointing me in right direction.

import matplotlib.pyplot plt import numpy np x=np.array([1,2,3,4,5,6,7]) y=np.sin(x) fig = plt.figure('test figure') sub1=fig.add_subplot(1,1,1) sub1.plot(x,y) 

generates following error

traceback (most recent call last):   file "c:\users\u999999\desktop\code\simple_example.py", line 7, in <module> fig = plt.figure('test figure')   file "c:\python\lib\site-packages\matplotlib\pyplot.py", line 241, in figure num = int(num)  # crude validation of num argument valueerror: invalid literal int() base 10: 'test figure' 

added comments

i'm using matplotlib version 0.99.3rc1

the functionality trying access passing in a text label num. put figure number here, can put in number or string label.

this functionality has been available since this commit in june 2011. first release version in version 1.1.0. you're on version 0.99.3rc2 - feature won't available. best advice upgrade (pretty old!) version unless there's strong reason not to.


details

the line of code enables pass string in place of integer figure number here, short block of code reproduced below illuminate point - first argument matplotlib.pyplot.figure() named num , defaults none:

#snippet matplotlib.pyplot.figure()  if num none:     num = next_num elif is_string_like(num):     figlabel = num     alllabels = get_figlabels()     if figlabel not in alllabels:         if figlabel == 'all':             warnings.warn("close('all') closes existing figures")         num = next_num     else:         inum = alllabels.index(figlabel)         num = allnums[inum] 

Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

Nuget pack csproj using nuspec -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -