Python: Using variables in Pylab Titles


Question

I have variables N and W which change with each run. Is it possible to do something like the following?:

pylab.title('Minimal Energy Configuration of' N 'Charges on Disc' 'W = 'W)
1
10
2/13/2014 9:15:21 AM

Accepted Answer

I think your talking about string interpolation like this :

pylab.title('Minimal Energy Configuration of %s Charges on Disc W = %s'%(N, W))
20
5/27/2011 7:56:04 AM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon