Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python: Using variables in Pylab Titles

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)
like image 944
Bob Avatar asked May 27 '11 02:05

Bob


People also ask

How do you put a variable in a plot title in Python?

Create data points for x and y using numpy and num (is a variable) to calculate y and set this in title. Plot x and y data points using plot() method with red color. Set the title of the curve with variable num. To display the figure, use show() method.

What is the difference between PyLab and Matplotlib?

PyLab is a procedural interface to the Matplotlib object-oriented plotting library. Matplotlib is the whole package; matplotlib. pyplot is a module in Matplotlib; and PyLab is a module that gets installed alongside Matplotlib. PyLab is a convenience module that bulk imports matplotlib.

What is the function of PLT title () method in Matplotlib?

The title() method in matplotlib module is used to specify title of the visualization depicted and displays the title using various attributes.


1 Answers

I think your talking about string interpolation like this :

pylab.title('Minimal Energy Configuration of %s Charges on Disc W = %s'%(N, W))
like image 139
Cédric Julien Avatar answered Oct 30 '22 07:10

Cédric Julien