Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example of embedding a figure into an existing Tk canvas #3546

Merged

Conversation

alexeicolin
Copy link

A new example that shows how to embed a matplotlib figure into an existing canvas at an arbitrary location. This is useful for integrating matplotlib output with graphical output that is already created using Tk drawing and not subject to be ported into matplotlib.

This example complements embedding_in_tk.py and embedding_in_tk2.py both of which use the FigureCanvasTkAgg function which creates a new Tk canvas.

embedding_in_tk_canvas

@tacaswell tacaswell added this to the v1.5.x milestone Sep 21, 2014
@tacaswell
Copy link
Member

If I am understanding this code right, it creates a temporary Agg canvas, draws the figure, copies the Agg buffer to a TK photo object, and then draws the photo on to the existinc canvas?

👍 from me, but someone who know TK should take a look at this.

@alexeicolin
Copy link
Author

@tacaswell yep. I found this useful for adding a matplotlib plot to an existing diagramming application that was drawing the diagrams using TkInter Python bindings -- the x-axis of the plot had to be matched with the axis of the Tk diagram, so it was best to literally insert the plot into the same Tk canvas.

tacaswell added a commit that referenced this pull request Oct 28, 2014
…canvas

DOC : Example of embedding a figure into an existing Tk canvas
@tacaswell tacaswell merged commit c9898ea into matplotlib:master Oct 28, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants