The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> Python Programming
|
Drawing isosceles triangle using python Pyplot/Matplotlib
Discuss Drawing isosceles triangle using python Pyplot/Matplotlib in the Python Programming forum on Dev Shed. Drawing isosceles triangle using python Pyplot/Matplotlib Python Programming forum discussing coding techniques, tips and tricks, and Zope related information. Python was designed from the ground up to be a completely object-oriented programming language.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

November 18th, 2012, 03:38 PM
|
|
Registered User
|
|
Join Date: Nov 2012
Posts: 2
Time spent in forums: 18 m 51 sec
Reputation 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 ?
Thanks in advance.
|

November 19th, 2012, 10:21 AM
|
 |
Contributing User
|
|
|
|
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)
__________________
[code] Code tags[/code] are essential for python code!
|

November 19th, 2012, 11:09 AM
|
|
Registered User
|
|
Join Date: Nov 2012
Posts: 2
Time spent in forums: 18 m 51 sec
Reputation Power: 0
|
|
Thanks for the reply
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 ?
Quote: | 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)
|
|

November 19th, 2012, 11:30 AM
|
 |
Contributing User
|
|
|
|
|
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.
|

November 19th, 2012, 12:31 PM
|
 |
Contributing User
|
|
|
|
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()
__________________
Real Programmers always confuse Christmas and Halloween because Oct31 == Dec25
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|