From: John H. <jdh...@ac...> - 2003-12-29 15:45:41
|
>>>>> "Eugene" == Eugene A Suchkov <Cit...@in...> writes: Eugene> When I'm performing smth like: Eugene> tl=get_xticklabels(...) for l in tl: print get_text(l) Eugene> I'm wondering why tl is a correct list, but with empty Eugene> text :( This is related to the first problem you are having. When you are not running matplotlib in interactive mode, nothing on the plotting side is done until you call 'show()'. The reason for this is that the backend doesn't have access to the gtk primitives until the window is realized. If you start your script with >>> import matplotlib >>> from matplotlib.matlab import * >>> from matplotlib.backends.backend_gtk import ShowOn >>> ShowOn().set(1) # turning on interactive mode and turn on interactive mode, then you can, for example, print the labels before calling show, as in the script below. Note however, whether or not you are in interactive mode, you will be able to control the text properties, as in ax = subplot(111) ax.plot([1,2,3]) tl = ax.get_ticklabels() set(tl, 'color', 'r') You aren't the first one to be confused about interactive mode vis-a-vis the various backends. It's not a trivial issue since both the GTK and WX backend have event loops that they go into, but it's a high priority since it's causing trouble for several people. Hopefully by the next minor release we'll have it worked out..... import matplotlib from matplotlib.matlab import * from matplotlib.backends.backend_gtk import ShowOn ShowOn().set(1) # turning on interactive mode t = arange(0.0, 3.0, 0.01) s = sin(2*pi*t) ax = subplot(111) ax.plot(t,s) tl = ax.get_xticklabels() for l in tl: print l.get_text() show() |