On 27 August 2010 09:35, xyz <mit...@op.pl> wrote:

> Hello,
> I would like to draw the following  triangle:
>
>         A
>        / \
>     5 /   \ 5
>      /     \
>     /       \
>    B--------C
>        4
>
> How is it possible to draw the above triangle with Matplotlib and are
> there any examples?
>

How about:

import matplotlib.pyplot as plt
from matplotlib.patches import Polygon
pts = np.array([[0,0], [4,0], [2,np.sqrt(5**2 - 2**2)]])
p = Polygon(pts, closed=True)
ax = plt.gca()
ax.add_patch(p)
ax.set_xlim(0,4)
ax.set_ylim(0,5)
plt.show()

I looked at the example here:
http://matplotlib.sourceforge.net/examples/api/bbox_intersect.html,
found through the gallery here:
http://matplotlib.sourceforge.net/gallery.html  for inspiration.

Angus.
-- 
AJC McMorland
Post-doctoral research fellow
Neurobiology, University of Pittsburgh
------------------------------------------------------------------------------
Sell apps to millions through the Intel(R) Atom(Tm) Developer Program
Be part of this innovative community and reach millions of netbook users 
worldwide. Take advantage of special opportunities to increase revenue and 
speed time-to-market. Join now, and jumpstart your future.
http://p.sf.net/sfu/intel-atom-d2d
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to