how to decrease right margin and move colorbar?

I am creating a scatter plot using pyplot.scatter(), and adding a colorbar
via pyplot.colorbar(). The result is very nice, except that there is a
large amount of empty space between the right-hand edge of the axes and the
figure window. When I adjust the right-hand margin using something like
pyplot.subplots_adjust(right=0.95), the right-hand margin is in fact
reduced, but the colorbar remains in the same location and is consequently
inside the axes. Any advice will be appreciated.

···


View this message in context: http://www.nabble.com/how-to-decrease-right-margin-and-move-colorbar--tp25829194p25829194.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

Dr. Phillip M. Feldman wrote:

I am creating a scatter plot using pyplot.scatter(), and adding a colorbar
via pyplot.colorbar(). The result is very nice, except that there is a
large amount of empty space between the right-hand edge of the axes and the
figure window. When I adjust the right-hand margin using something like pyplot.subplots_adjust(right=0.95), the right-hand margin is in fact
reduced, but the colorbar remains in the same location and is consequently
inside the axes. Any advice will be appreciated.

Try calling subplots_adjust(right=0.99) before calling colorbar. Then the colorbar axes will be generated by stealing space from the enlarged main axes.

Eric