How to embed a Matplotlib graph to your Tkinter GUI

Since we are creating a bitcoin trading application, it only makes sense that we're going to have to incorporate some price data. Not only do we want to just plot the prices, but many people will want to see prices in the form of OHLC candlesticks, and then others will also want to see various indicators like EMA/SMA crossovers and things like RSI or MACD.

To do this, we first need to know how to actually embed a Matplotlib graph into a Tkinter application. Here's how!

First, we're going to be using Matplotlib, so, if you do not have it, you will need to get it. There are many ways to get Matplotlib, head over to Matplotlib.org to download.

You can also use pip to install using: pip install matplotlib in cmd.exe / bash.

If you need help with pip, check out the .

Now we're going to need to add the following imports to our Tkinter application:

The first just imports the Matplotlib module. Next, we specifiy the backend, "TkAgg" that we wish to use with Matplotlib. Normally, using the default is perfectly fine, but we need to change this for our uses here.

Next, we import the FigureCanvasTkAgg as well as the navigation bar that is used with Matplotlib.

Finally, we import Figure. We will just be temporarily using this Figure, but that's okay.