From: <fcc...@fi...> - 2005-02-11 14:30:22
|
hi, how can I remove a colorbar? in the following code, i generate figures that are saved not shown. and with every new figure I get an extra colorbar instead of an updated one! from matplotlib.pylab import * from RandomArray import * imshow(normal(0,1,(256,256))) title('distance matrix') colorbar() savefig('dm.png') imshow(normal(0,1,(256,256))+20) title('conectivity matrix') colorbar() savefig('cm.png') there should be a way to toggle a color bar on and off. Flávio |
From: John H. <jdh...@ac...> - 2005-02-13 01:51:33
|
>>>>> "Fl=E1vio" =3D=3D Fl=E1vio Code=E7o Coelho <fcc...@fi...> wr= ites: Fl=E1vio> hi, how can I remove a colorbar? Fl=E1vio> in the following code, i generate figures that are saved Fl=E1vio> not shown. and with every new figure I get an extra Fl=E1vio> colorbar instead of an updated one! Hi Flavio, Try clearing the figure between saves with clf. Or else manage the different figures the "figure" and "close" commands. The default mode of matplotlib is to continue adding stuff to the same figure, so you need to clear axes with "cla", clear figures with "clf", close figures with "close", create new figures with "figure", and manage the hold state with "hold", "ion", "ioff" and "ishold". See the documentation for all of these commands at http://matplotlib.sf.net/matplotlib.pylab.html Hope this helps, JDH |
From: <fcc...@fi...> - 2005-02-14 11:12:54
|
On Saturday 12 February 2005 23:40, John Hunter wrote: > >>>>> "Fl=E1vio" =3D=3D Fl=E1vio Code=E7o Coelho <fcc...@fi...> wr= ites: > > Fl=E1vio> hi, how can I remove a colorbar? > > Fl=E1vio> in the following code, i generate figures that are saved > Fl=E1vio> not shown. and with every new figure I get an extra > Fl=E1vio> colorbar instead of an updated one! > > Hi Flavio, > > Try clearing the figure between saves with clf. Or else manage the > different figures the "figure" and "close" commands. > > The default mode of matplotlib is to continue adding stuff to the same > figure, so you need to clear axes with "cla", clear figures with > "clf", close figures with "close", create new figures with "figure", > and manage the hold state with "hold", "ion", "ioff" and "ishold". > See the documentation for all of these commands at > http://matplotlib.sf.net/matplotlib.pylab.html > > Hope this helps, > JDH > Thanks John, I just want to let you know that neither 'cla', 'clf' nor 'figure' solved t= he=20 issue but 'close' did it. I must point out that the only element that was= =20 being carried out from figure to figure was the colorbar, not the plot=20 itself. Apparently 'close' is the only one of these functions that gets rid= =20 of the colorbar. =46l=E1vio=20 |
From: John H. <jdh...@ac...> - 2005-02-14 14:35:37
|
>>>>> "Fl=E1vio" =3D=3D Fl=E1vio Code=E7o Coelho <fcc...@fi...> wr= ites: Fl=E1vio> I just want to let you know that neither 'cla', 'clf' nor Fl=E1vio> 'figure' solved the issue but 'close' did it. I must Fl=E1vio> point out that the only element that was being carried out Fl=E1vio> from figure to figure was the colorbar, not the plot Fl=E1vio> itself. Apparently 'close' is the only one of these Fl=E1vio> functions that gets rid of the colorbar. Hi Fl=E1vio, clf *should* work. Could you send me a script which includes a clf that replicates the problem so I can fix it. Thanks. JDH |
From: <fcc...@fi...> - 2005-02-15 12:08:54
Attachments:
testcolorbar.py
|
On Monday 14 February 2005 12:24, John Hunter wrote: > >>>>> "Flávio" == Flávio Codeço Coelho <fcc...@fi...> writes: > > Flávio> I just want to let you know that neither 'cla', 'clf' nor > Flávio> 'figure' solved the issue but 'close' did it. I must > Flávio> point out that the only element that was being carried out > Flávio> from figure to figure was the colorbar, not the plot > Flávio> itself. Apparently 'close' is the only one of these > Flávio> functions that gets rid of the colorbar. > > Hi Flávio, > > clf *should* work. Could you send me a script which includes a clf > that replicates the problem so I can fix it. Thanks. > Hi John, clf does work, sorry. Its cla that does not (though I am not sure it should serve this purpose...) i am sending the code attached |
From: John H. <jdh...@ac...> - 2005-02-15 13:57:22
|
>>>>> "Fl=E1vio" =3D=3D Fl=E1vio Code=E7o Coelho <fcc...@fi...> wr= ites: Fl=E1vio> I just want to let you know that neither 'cla', 'clf' nor Fl=E1vio> 'figure' solved the issue but 'close' did it. I must Fl=E1vio> point out that the only element that was being carried out Fl=E1vio> from figure to figure was the colorbar, not the plot Fl=E1vio> itself. Apparently 'close' is the only one of these Fl=E1vio> functions that gets rid of the colorbar. Yep, cla would not be expected to do anything, since both the image and colorbar are spearate axes. So cla, clf and close are working as advertised -- and that's a good thing :-) JDH |