-3

Hey,

can somebody help me. I have to do a programm from school. I a complete newbie in python.
Can somebody tell me why my programm doesn't work and what i can do. thanks

here it is:

import matplotlib 
import numpy
import pylab



lam = pylab.linspace(0.1,100,1000)*10**-6

pylab.xlabel('Wellenlaenge (mM)')
pylab.ylabel('Temperatur (T)')
pylab.title('Mac Plank')




c1  = 0.374*10**-15
c2  = 1.439*10**-2


p= lamda x,t : (c1/(x**5))*(1/(2.7183**(c2/x*t))-1)

pylab.plot (lam*1e6,p(lam,300))

for t in (300,400,600,800,1000): pylab.plot(lam*1e6, p(lam,t)

Edited by Nick Evan: added code tags

3
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by woooee
Featured Replies
  • 1

    A line is more than a single point if you are trying to code a line. I don't know. You didn't say. But if you want a bar graph for example then you have to code for a bar, see this example from the matplotlib docs [url]http://matplotlib.sourceforge.net/examples/pylab_examples/barchart_demo.html[/url] Take a look … Read More

0

Hey,

import matplotlib 
import numpy
import pylab



lam = pylab.linspace(0.1,100,1000)*10**-6

pylab.xlabel('Wellenlaenge (mM)')
pylab.ylabel('Temperatur (T)')
pylab.title('Mac Plank')




c1  = 0.374*10**-15
c2  = 1.439*10**-2


p= lamda x,t : (c1/(x**5))*(1/(2.7183**(c2/x*t))-1)

pylab.plot (lam*1e6,p(lam,300))

for t in (300,400,600,800,1000): pylab.plot(lam*1e6, p(lam,t)

end quote.

You have unterminated parenthesis in the last line at least. I am not using pylab myself (yet).

Do you see how much nicer the code looks if you first click the (CODE) before pasting your code?

Tony

Edited by mike_2000_17: Fixed formatting

0

Can somebody tell me why my programm doesn't work and what i can do

Not without more info. Please include the traceback message at a minimum, with a simple explanation of what isn't working.

0

It now looks like this.My Problem is that it does't work and i don't know why.
At the end, a window should open and show me the graph.
the the window is empty with no graph.but why.what do i have to change that it works?

import numpy as np
import pylab as plt
from math import exp, e
from matplotlib.pyplot import legend, xlim, ylim, show



lam = np.linspace (0.1,100,1000)*10**-6
c1=0.374e-15
c2=1.439e-2   




  
def lamda(x):
   
   return ((c1/(x**5))*(1/(exp(c2/x*300))-1))
   
   
plt.plot(lam,lamda(lam))


legend()

xlim(0, 10)
ylim(0, 14000)

plt.xlabel('Wellenlaenge(muekrometer)')
plt.ylabel('Spektrale Energieflussdichte(W/m^2muekrometer)')
plt.title('Planck')


show()

Edited by Nick Evan: added code tags

1

A line is more than a single point if you are trying to code a line. I don't know. You didn't say. But if you want a bar graph for example then you have to code for a bar, see this example from the matplotlib docs http://matplotlib.sourceforge.net/examples/pylab_examples/barchart_demo.html Take a look at Ene's example here as well http://www.daniweb.com/code/snippet216915.html I'm outta here. Your descriptions are too vague and I'm sorry, but don't have the time to try and intuit what it is you are trying to do.

Edited by woooee: n/a

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.