can someone help me to plot a polygon in matplotlib?
I have been reading about the axes.patches.Polygon class and I have defined the
Polygon object that has a preset lw and points. How do I plot it?
I’m confused because the Axes documentation states that this class holds most of
the figure objects like Rectangle, Line2D, and then the website states that the Line2D
is a return object from the plt.plot() invocation. What if I create my own set of Rectangle
(Polygon) objects and want to create a list of them and plot them?
Also, I’m using this sequence of commands to work in OO mode interactively
(just to learn) but when I execute plt.draw() no figure appears.
import numpy as np
import matplotlib.pyplot as plt
myFig = plt.figure()
myAx = myFig.add_axes() # I have tried myFig.add_subplot(1,1,1) but it didn’t help
x = np.arange(0,np.pi, 0.01)
myAx.plot (x, np.sin(x))
plt.draw() # nothing happens
These commands are executed within an interactive ipython session but if I start ipython
with ipython -pylab, plt.draw() draws a figure I can see. I’m running Arch linux and Openbox
as a window manager, the system is 64 bit.