### Thread: Drawing isosceles triangle using python Pyplot/Matplotlib

1. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Nov 2012
Posts
2
Rep Power
0

#### Drawing isosceles triangle using python Pyplot/Matplotlib

Hi all,
I'm trying to plot to isosceles triangle with two equals sides with * using pyplot or matplot lib module in python.
I couldn't find api to draw triangle and i'm not very familiar with the library. Does anyone know how to do it ?
2. Why do you need matplotlib or pyplot? Why does your isosceles triangle need two equals sides?
Code:
```try:
import Tkinter as tkinter
except:
import tkinter

import time

iso = ((10,10,40,50,70,10,),(180,50,120,180,60,50,),)
canvas = tkinter.Canvas(width=400,height=200)
canvas.pack()
polygon = canvas.create_polygon(*(iso[0]))
colors = 'red green blue yellow orange'.split()
for i in range(9):
canvas.coords(polygon,*(iso[i&1]))
canvas.itemconfig(polygon,fill=colors[i%len(colors)])
canvas.update()
time.sleep(1)```
3. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Nov 2012
Posts
2
Rep Power
0
It can be either matplotlib or pyplot but it has to be one of them as i've requirement to use one of them .

Why does your isosceles triangle need two equals sides?
Isosceles triangles have two equal sides

Isn't tkinter different library altogether or is it part of matplotlib ?

Originally Posted by b49P23TIvg

Code:
```try:
import Tkinter as tkinter
except:
import tkinter

import time

iso = ((10,10,40,50,70,10,),(180,50,120,180,60,50,),)
canvas = tkinter.Canvas(width=400,height=200)
canvas.pack()
polygon = canvas.create_polygon(*(iso[0]))
colors = 'red green blue yellow orange'.split()
for i in range(9):
canvas.coords(polygon,*(iso[i&1]))
canvas.itemconfig(polygon,fill=colors[i%len(colors)])
canvas.update()
time.sleep(1)```
4. http://exnumerus.blogspot.com/2011/02/how-to-quickly-plot-polygons-in.html

you wrote the redundant sentence

And what do you mean by "with *"?

Yes, tkinter uses tcl. matplotlib seems to use gtk.
5. Experiment with something like that:
Code:
```import matplotlib.pyplot as plt

plt.plot([1,2,3])

plt.plot([3,2,1])

plt.plot([2,2,2])

plt.show()```