Abhinav Verma wrote:
Yes Eric this is what I wanted and Many thanks for your help.
My question now extends a little. Due to this .. my yaxis label is truncated in the png. How can I make sure that my figure is square and also contains everything. Is it possilbe?
There is no standard automatic method; you have to adjust the position of the axes within the figure. You can either specify the position explicitly by using
ax = fig.add_axes([l,b,w,h]
in place of add_subplot, and with l, b, w, h being left, bottom, width, and height in normalized coordinates (i.e., fractions of the figure window), or you can use fig.add_subplot together with fig.subplots_adjust(**kwargs).
Either way, to figure out how to set the l,b,w,h, you can first make the plot interactively and use the "Configure subplots" tool (next to last on the right) in the toolbar to interactively adjust the axes position and to show you what the values are that make it look right.
The default axes and subplot positioning parameters are also available via rcParams.