Print variable in large font in python figure
Question: I have borrowed some code from another source and I want to edit the figure
produced. Here is the relevant (i think) code from the script.

    
    
    import gtk #the gui toolkit we'll use:
    from matplotlib.figure import Figure
    from Tkinter import *
    from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg as FigureCanvas
    
    #create a window to put the plot in
    win = gtk.Window()
    #connect the destroy signal (clicking the x in the corner)
    win.connect("destroy", quit_app)
    win.set_default_size(600,500)
    
    #create a plot:
    fig = Figure()
    ax = fig.add_subplot(111,xlabel='Time Step', ylabel='Temp (deg C)', axisbg='black')
    ax.set_ylim(0,100) # set limits of y axis.
    
    canvas = FigureCanvas(fig) #put the plot onto a canvas
    win.add(canvas) #put the canvas in the window
    
    #show the window
    win.show_all()
    win.set_title("ready to receive data");
    line, = ax.plot(times,yvals, color='red')
    
    while(1):
      line.set_ydata(yvals) # draw the line
      fig.canvas.draw() # update the Canvas
      win.set_title("Temp: "+str(yvals[49])+" deg C")
    

I don't know whether or not all the code above is necessary - but that is all
the 'plot' related code I could find.

So anyway the code works in my program perfectly.

There are TWO tasks I would like to create: (1) What I want is to include that
'str(yvals[49])' variable, which is currently being displayed in the title of
the window, to be displayed in large font underneath the plot. So I think I
need to make the window size a little bigger to accompany the text but not
sure how to print it.

(2) I manged to change the background of the plot itself to black that plots a
red line. But how can I change the background of the window itself to all
black and the x/y axis to red as well.

Thanks!!


Answer: (1) What you are most probably looking for it the matplotlib text command.
Have a look at <http://matplotlib.org/users/pyplot_tutorial.html> section
working with text. It might be convenient to create two separate axes, so you
can truly put the text below the whole figure. Maybe it is enough to place the
text at xlabel position?

    
    
    import matplotlib.pyplot as plt
    plt.xlabel('yourtext')
    

(2) There are already good answers out there that might help you: e.g. [How to
change the pylab window background
color?](http://stackoverflow.com/questions/16896341/how-to-change-the-pylab-
window-background-color) As for the color of the axis [Changing the color of
the axis, ticks and labels for a plot in
matplotlib](http://stackoverflow.com/questions/4761623/changing-the-color-of-
the-axis-ticks-and-labels-for-a-plot-in-matplotlib)

Have also a look at [Matplotlib figure facecolor (background
color)](http://stackoverflow.com/questions/4804005/matplotlib-figure-
facecolor-background-color) in case you want to save the figure.

