Ryan May wrote:
> Yves Revaz wrote:
>
>> Hi all,
>>
>> When I use:
>>
>> colorbar(orientation='horizontal')
>>
>> the color bar is drawn on the bottom of the corresponding graph.
>> Which option will draw the colorbar on the top of the graph ?
>>
>
> I think (correct me if I'm wrong devs) you'll have to use the cax
> keyword argument to manually specifiy the position of the axes in which
> to draw the colorbar. You'll also need to adjust the position of the
> plot using figure.subplots_adjust. Like this maybe:
>
> import numpy as np
> import matplotlib.pyplot as plt
> data = np.random.randn(30,30)
> plt.pcolor(data)
> fig = plt.gcf()
> fig.subplots_adjust(top=0.85)
> ax = fig.add_axes([0.12, 0.9, 0.8, 0.05])
> plt.colorbar(cax=ax, orientation='horizontal')
>
> Hope this helps,
>
>
ok, it works fine for that case.
Now, my problem is that my graph is a subplot:
Taking your example it corresponds to :
import numpy as np
import matplotlib.pyplot as plt
fig = plt.gcf()
plt.subplot(2,2,2)
data = np.random.randn(30,30)
plt.pcolor(data)
fig.subplots_adjust(top=0.85)
ax = fig.add_axes([0.12, 0.9, 0.8, 0.05])
plt.colorbar(cax=ax, orientation='horizontal')
plt.show()
Obviously, the colorbar has now the length of the whole figure and not
the one
of the subplot ! :-(
I should do a "subplots_adjust" to the subplot and not to the "fig", but
how can I do that ?
Thanks,
yves
> Ryan
>
> --
> Ryan May
> Graduate Research Assistant
> School of Meteorology
> University of Oklahoma
>
--
(o o)
--------------------------------------------oOO--(_)--OOo-------
Yves Revaz
Laboratory of Astrophysics EPFL
Observatoire de Sauverny Tel : ++ 41 22 379 24 28
51. Ch. des Maillettes Fax : ++ 41 22 379 22 05
1290 Sauverny e-mail : [EMAIL PROTECTED]
SWITZERLAND Web : http://www.lunix.ch/revaz/
----------------------------------------------------------------
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users