[Matplotlib-users] Why are all my plots displayed as closed loops?

Paul D. DeRocco pderocco at ix.netcom.com
Sun Jun 5 02:56:19 EDT 2016

> From: Thomas Caswell [mailto:tcaswell at gmail.com] 
> `Line2D` draws lines connecting the points in the order you 
> pass them in.  If mpl sorted your data based on the x values 
> then you could never plot anything was not a single valued 
> function f(x).

That's fine, but in this case that's exactly what I'm trying to plot, so
I'm giving it ascending x values. But it's connecting the last point back
to the first point, for no obvious reason. I won't try to post the screen
caps in the mailing list, which I expect doesn't work, but they are at
still at http://preview.tinyurl.com/hb62una for now. But here's the code:

import numpy
import gtk
import matplotlib
from matplotlib.figure import Figure
from matplotlib.backends.backend_gtk import FigureCanvasGTK as

class junk:

    def __init__(self):

        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.connect('destroy', self.destroy)
        self.window.resize(400, 400)

        self.figure = Figure()
        self.axes = self.figure.add_axes((0, 0, 1, 1))
        self.canvas = FigureCanvas(self.figure)


        self.axes.set_xlim(-10, 12)
        self.axes.set_ylim(-1, 122)
        x = numpy.arange(-9, 12)
        self.axes.plot(x, x * x)



    def destroy(self, widget, data = None):


    def main(self):


if __name__ == '__main__':

    app = junk()

Do you get the same results? How do I make it not do that?


Ciao,               Paul D. DeRocco
Paul                mailto:pderocco at ix.netcom.com

More information about the Matplotlib-users mailing list