|
From: Joe K. <jof...@gm...> - 2014-03-13 15:08:39
|
That should be `matplotlib.use('TkAgg')`, not "Agg". Agg is a
non-interactive backend, while TkAgg is an interactive Tkinter wrapper
around the Agg backend.
On Thu, Mar 13, 2014 at 9:53 AM, Jeroen Hegeman <jer...@gm...>wrote:
> Hi Christophe,
>
> This is (I think) a known limitation of the OS X backend. One way around
> this is to use another backend. Which backends are available depends on how
> your matplotlib was built. (And unfortunately I don't know how to figure
> out which ones are available, apart from trying.) In my case (matplotlib
> from homebrew on OS X 10.9.2) the TkAgg backend works.
>
> To use the TkAgg backend insert these two lines:
> import matplotlib
> matplotlib.use('Agg')
> before the line
> import matplotlib.pyplot as plt
>
> I hope that helps.
>
> Best regards,
> Jeroen
>
>
> On 13 Mar 2014, at 15:33, Christophe Bal <pro...@gm...> wrote:
>
> > Hello,
> > I'm a little disappointed by the following test program coming from this
> post.
> >
> > What are the technical reasons that make fail the following code under
> Mac O$ ?
> >
> > Best regards.
> > Christophe BAL
> >
> > ---- TEST ---
> >
> > from random import randint,
> > choice
> >
> > import
> > time
> >
> > import matplotlib.pyplot as
> > plt
> >
> > import matplotlib.patches as
> > mpatches
> >
> > back_color
> > = "black"
> >
> > colors
> > = ['red', 'green', 'cyan', 'yellow']
> >
> > width
> > , height = 16, 16
> >
> >
> > fig
> > , ax = plt.subplots()
> >
> > ax
> > .set(xlim=[0, width], ylim=[0, height]) # Or use "ax.axis([x0,x1,y0,y1])"
> >
> >
> >
> > # Be sure to draw the canvas once before we start blitting. Otherwise
> > # a) the renderer doesn't exist yet, and b) there's noting to blit onto
> >
> > fig
> > .canvas.draw()
> >
> >
> >
> > def update():
> >
> > x
> > = randint(0, width - 1)
> >
> > y
> > = randint(0, height - 1)
> >
> >
> > rect
> > = mpatches.Rectangle(
> >
> >
> > (x, y), 1, 1,
> >
> > facecolor
> > = choice(colors),
> >
> > edgecolor
> > =
> > back_color
> >
> > )
> >
> > ax
> > .add_artist(rect)
> >
> >
> > start
> > = time.time()
> >
> > ax
> > .draw_artist(rect)
> >
> > fig
> > .canvas.blit(ax.bbox)
> >
> >
> > print("draw >>>", time.time() - start)
> >
> >
> > timer
> > = fig.canvas.new_timer(interval=1)
> >
> > timer
> > .add_callback(update)
> >
> > timer
> > .start()
> >
> >
> > plt
> > .show()
> >
> ------------------------------------------------------------------------------
> > Learn Graph Databases - Download FREE O'Reilly Book
> > "Graph Databases" is the definitive new guide to graph databases and
> their
> > applications. Written by three acclaimed leaders in the field,
> > this first edition is now available. Download your free book today!
> >
> http://p.sf.net/sfu/13534_NeoTech_______________________________________________
> > Matplotlib-users mailing list
> > Mat...@li...
> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
>
> ------------------------------------------------------------------------------
> Learn Graph Databases - Download FREE O'Reilly Book
> "Graph Databases" is the definitive new guide to graph databases and their
> applications. Written by three acclaimed leaders in the field,
> this first edition is now available. Download your free book today!
> http://p.sf.net/sfu/13534_NeoTech
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
|