Re: [Matplotlib-users] square plots with linear equal axes -- help

2009-07-26 Thread kbkb

Thanks for trying to help Andreas.

Those suggestions did not really solve the problem, but I did realize where
I was going astray and post that information here to help others.  I did see
others new to the libraries looking for similar help.

First the conceptual misunderstanding:  I did not realize the 'figure size',
as set by something like
plt.gcf().set_size_inches(6,6) includes all area: white plot area, grey
surrounding area, labels, etc.  Everything inside the window frame.  A bad
coincidence slowed my realization.  I measured the white area inside the
axis to be 480x464 pixels, which  at 80 dpi worked almost for a 6x6.  So, I
thought it was close but off just a bit.  But, I had set the dpi to 100, and
the total frame was exactly 600x600 as it should be.  The dimensions of the
plot area inside the axes was being set automatically, and just
coincidentally worked out to be 480 in one dimension.

Solution to get truly square plots of known size with axis scale set:
fig = plt.gcf()
fig.set_dpi(100)  # or whatever you like
fig.set_size_inches((6.0,6.0),forward=True) #for example
# to control the fraction of the total area set aside for axis tick mark
labels, etc. 
# this is key to keeping the interior plot area square
plt.subplots_adjust(left=0.10,bottom=0.10,right=0.95,top=0.95) 
## plt.axis('equal')  # I had this for a while but do not think it
useful
plt.gca().grid(True)
# to keep the axis scale from being automatically changed as line2d
objects are added or removed
plt.gca().set_autoscale_on(False)  
plt.axis([1.0,9.0,1.0,9.0])  # set the axis scale as appropriate
plt.show() 
fig.canvas.draw()

Cheers
Kersey

-- 
View this message in context: 
http://www.nabble.com/square-plots-with-linear-equal-axes-help-tp24638812p24672100.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] square plots with linear equal axes -- help

2009-07-25 Thread kbkb

Hi
This should be so simple, but I have been struggling for a long time trying
to create a square plot of exact dimensions (so a series of them can be
overlaid later), with x and y axis limits identical and set by me
(preferably without the plot limits updating automatically as I add or
delete data, but that is a separate issue), while working interactively on a
single plot using pyplot in ipython on OS X using the current enthought
distribution.

with pyplot imported as plt,
typical of what I have tried are many variations on 

plt.plot(*args) with args a list of x,y
sets
fig = plt.gcf()
fig.set_size_inches(6,6,forward='True')to force a redraw
ax = plt.gca()
ax.grid(True)
plt.axis([1.0,10.0,1.0,10.0])
plt.draw()

Sometimes the x axis is set correctly, but the y axis is not, and is
typically showing more range (approximately 0.8-10.1 for example), possibly
because the plot is not square, though it is close, or because the scales
are not equal.

I have tried adding 'equal' to the plt.axis command, 
and entering the values as
plt.axis(xmin=1.0,xmax=10.0,ymin=1.0,ymax=10.0)
and entering just the first three and then
plt.axis('equal')
and I have tried working with 
ax.set_aspect('equal')

But, I am truly lost as I try to sort out which elements are in control.
Any help or leads would be greatly appreciated.  
Scanning old archives and googling has not yet got me there.   

kersey
-- 
View this message in context: 
http://www.nabble.com/square-plots-with-linear-equal-axes-help-tp24638812p24638812.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users