@@ -13,9 +13,9 @@ Axes to inspect your data is 'baked in' to Matplotlib. This is
1313supported by a full mouse and keyboard event handling system that
1414you can use to build sophisticated interactive graphs.
1515
16- This is meant to be an introduction to the low-level details of how
17- integrating the Matplotlib with a GUI event loop works. For a more
18- practical introduction the Matplotlib event API see :ref: `event
16+ This guide is meant to be an introduction to the low-level details of
17+ how Matplotlib integration with a GUI event loop works. For a more
18+ practical introduction to the Matplotlib event API see :ref: `event
1919handling system <event-handling-tutorial>`, `Interactive Tutorial
2020<https://github.com/matplotlib/interactive_tutorial> `__, and
2121`Interactive Applications using Matplotlib
@@ -45,7 +45,7 @@ while the *Evaluate* and *Print* are responsible for interpreting the
4545input and then **doing ** something about it.
4646
4747In practice we interact with a framework that provides a mechanism to
48- register callbacks to be called in response to specific event rather
48+ register callbacks to be run in response to specific events rather
4949than directly implement the I/O loop [#f2 ]_. For example "when the
5050user clicks on this button, please run this function" or "when the
5151user hits the 'z' key, please run this other function". This allows
@@ -60,10 +60,9 @@ All GUI frameworks (Qt, Wx, Gtk, tk, OSX, or web) have some method of
6060capturing user interactions and passing them back to the application
6161(for example ``Signal `` / ``Slot `` framework in Qt) but the exact
6262details depend on the toolkit. Matplotlib has a :ref: `backend
63- <what-is-a-backend>` for each GUI toolkit we support which use the
64- toolkit API to bridge the toolkit UI events into Matplotlib events
65- into Matplotlib's :ref: `event handling system
66- <event-handling-tutorial>`. You can then use
63+ <what-is-a-backend>` for each GUI toolkit we support which uses the
64+ toolkit API to bridge the toolkit UI events into Matplotlib's :ref: `event
65+ handling system <event-handling-tutorial>`. You can then use
6766`.FigureCanvasBase.mpl_connect ` to connect your function to
6867Matplotlib's event handling system. This allows you to directly
6968interact with your data and write GUI toolkit agnostic user
@@ -77,8 +76,8 @@ Command Prompt Integration
7776
7877So far, so good. We have the REPL (like the IPython terminal) that
7978lets us interactively send things code to the interpreter and get
80- results back. We also have the GUI toolkit that run an event loop
81- waiting for user input and let up register functions to be run when
79+ results back. We also have the GUI toolkit that runs an event loop
80+ waiting for user input and lets us register functions to be run when
8281that happens. However, if we want to do both we have a problem: the
8382prompt and the GUI event loop are both infinite loops that each think
8483*they * are in charge! In order for both the prompt and the GUI windows
@@ -148,7 +147,7 @@ able to have a usable prompt **and** interactive figure windows.
148147
149148We can do this using the 'input hook' feature of the interactive
150149prompt. This hook is called by the prompt as it waits for the user
151- type (even for a fast typist the prompt is mostly waiting for the
150+ to type (even for a fast typist the prompt is mostly waiting for the
152151human to think and move their fingers). Although the details vary
153152between prompts the logic is roughly
154153
@@ -157,7 +156,7 @@ between prompts the logic is roughly
1571563. as soon as the user hits a key, exit the GUI event loop and handle the key
1581574. repeat
159158
160- This gives us the illusion of simultaneously having an interactive GUI
159+ This gives us the illusion of simultaneously having interactive GUI
161160windows and an interactive prompt. Most of the time the GUI event
162161loop is running, but as soon as the user starts typing the prompt
163162takes over again.
@@ -167,7 +166,7 @@ python is otherwise idle and waiting for user input. If you want the
167166GUI to be responsive during long running code it is necessary to
168167periodically flush the GUI event queue as described :ref: `above
169168<spin_event_loop>`. In this case it is your code, not the REPL, which
170- is blocking process so you need to handle the "time-share" manually.
169+ is blocking the process so you need to handle the "time-share" manually.
171170Conversely, a very slow figure draw will block the prompt until it
172171finishes drawing.
173172
@@ -220,7 +219,7 @@ event loop using the methods described :ref:`above <cp_block_the_prompt>`.
220219
221220You can also use the methods described in :ref: `cp_block_the_prompt `
222221to suspend run the GUI event loop. Once the loop exits your code will
223- resume. In general, anyplace you would use `time.sleep ` you can use
222+ resume. In general, any place you would use `time.sleep ` you can use
224223`.pyplot.pause ` instead with the added benefit of interactive figures.
225224
226225For example, if you want to poll for data you could use something like ::
@@ -280,7 +279,7 @@ For example ::
280279 slow_loop(100, ln)
281280
282281While this will feel a bit laggy (as we are only processing user input
283- every 100ms where as 20-30ms is what feels "responsive") it will
282+ every 100ms whereas 20-30ms is what feels "responsive") it will
284283respond.
285284
286285If you make changes to the plot and want it re-rendered you will need
@@ -304,7 +303,7 @@ We can add this our example above as ::
304303
305304The more frequently you call `.FigureCanvasBase.flush_events ` the more
306305responsive your figure will feel but at the cost of spending more
307- resource on the visualization and less on your computation.
306+ resources on the visualization and less on your computation.
308307
309308
310309.. _stale_artists :
@@ -315,10 +314,10 @@ Stale Artists
315314Artists (as of Matplotlib 1.5) have a **stale ** attribute which is
316315`True ` if the internal state of the artist has changed since the last
317316time it was rendered. By default the stale state is propagated up to
318- the Artists parents in the draw tree, thus if the color of a `.Line2D `
319- instance is changed, the `.axes.Axes ` and `.figure.Figure ` it is
320- contained in will also be marked as "stale". Thus, ``fig.stale `` will
321- report of any artist in the figure has been modified and out of sync
317+ the Artists parents in the draw tree, e.g., if the color of a `.Line2D `
318+ instance is changed, the `.axes.Axes ` and `.figure.Figure ` that
319+ contain it will also be marked as "stale". Thus, ``fig.stale `` will
320+ report if any artist in the figure has been modified and is out of sync
322321with what is displayed on the screen. This is intended to be used to
323322determine if ``draw_idle `` should be called to schedule a re-rendering
324323of the figure.
@@ -330,17 +329,17 @@ with the signature ::
330329 ...
331330
332331which by default is set to a function that forwards the stale state to
333- the artists parent. If you wish to suppress a given artist from propagating
332+ the artist's parent. If you wish to suppress a given artist from propagating
334333set this attribute to None.
335334
336335`.figure.Figure ` instances do not have a containing artist and their
337336default callback is `None `. If you call `.pyplot.ion ` and are not in
338- ``IPython `` we will install callback to invoke
339- `~.backend_bases.FigureCanvasBase.draw_idle ` when ever the
337+ ``IPython `` we will install a callback to invoke
338+ `~.backend_bases.FigureCanvasBase.draw_idle ` whenever the
340339`.figure.Figure ` becomes stale. In ``IPython `` we use the
341340``'post_execute' `` hook to invoke
342341`~.backend_bases.FigureCanvasBase.draw_idle ` on any stale figures
343- after having executed the users input, but before returning the prompt
342+ after having executed the user's input, but before returning the prompt
344343to the user. If you are not using `.pyplot ` you can use the callback
345344`Figure.stale_callback ` attribute to be notified when a figure has
346345become stale.
@@ -363,7 +362,7 @@ Draw Idle
363362In almost all cases, we recommend using
364363`backend_bases.FigureCanvasBase.draw_idle ` over
365364`backend_bases.FigureCanvasBase.draw `. ``draw `` forces a rendering of
366- the figure where as ``draw_idle `` schedules a rendering the next time
365+ the figure whereas ``draw_idle `` schedules a rendering the next time
367366the GUI window is going to re-paint the screen. This improves
368367performance by only rendering pixels that will be shown on the screen. If
369368you want to be sure that the screen is updated as soon as possible do ::
@@ -448,7 +447,7 @@ method. The source for the prompt_toolkit input hooks lives at
448447 .. [#f2 ] Or you can `write your own
449448 <https://www.youtube.com/watch?v=ZzfHjytDceU> `__ if you must.
450449
451- .. [#f3 ] These examples are agressively dropping many of the
450+ .. [#f3 ] These examples are aggressively dropping many of the
452451 complexities that must be dealt with in the real world such as
453- keyboard interupts , timeouts, bad input, resource
452+ keyboard interrupts , timeouts, bad input, resource
454453 allocation and cleanup, etc.
0 commit comments