How To Embed Matplotlib In TKinter Window

How To Embed Matplotlib In TKinter Window

In this Python TKinter article i want to show How To Embed Matplotlib In TKinter Window. for more TKinter articles check the below links.

 

 

What Is Matplotlib ? 

Matplotlib is a Python 2D plotting library which produces publication quality figures in a variety of hardcopy formats and interactive environments across platforms. Matplotlib can be used in Python scripts, the Python and IPython shells, the Jupyter notebook, web application servers, and four graphical user interface toolkits.

 

 

 

Also check more tkinter articles

1: Introduction To TKinter GUI Development

2: How To Create Label In Python TKinter

3: How To Create GUI Button In TKinter

4: How To Create TextBox In TKinter

5: How To Create ComboBox In TKinter

6: How To Create CheckButton In Python TKinter

7: How To Create RadioButton In Python TKinter

8: How To Create ScrollTextArea In TKinter

9: Python TKinter Creating LabelFrame

10: How To Create MenuItem In TKinter

11: Python TKinter Creating MenuItem Events

12: How To Create TabWidgets In TKinter

13: How Add Widgets In TKinter Tab Controls

14: How To Create MessageBox In TKinter

15: How To Create MultiChoiceBox In Python TKinter

16: How To Create ProgressBar In Python TKinter

17: How To Create ProgressBar In Python TKinter

18: How To Create Canvas In Python TKinter

 

 

 

 

So now this is the complete code for How To Embed Matplotlib In TKinter Window. make sure that you have installed Matplotlib in your computer . if you have not installed, you can installed by this command pip install matplotlib.

 

 

 

 

So at the top we have created our Root class that extends from TK, and we have added our window requirements like title, size and icon in the constructor of the class.

 

 

 

 

After that we have created our def matplotCanvas() method. in this method we have created our Figure also we have created the values that we want to plot. the important point is this that you need to created the object of FigureCanvasTKAgg().

 

 

 

This line of code is for creating NavigationToolbar for matplotlib window and we pass the object of canvas in that

 

 

 

 

 

Run the complete code and this will be the result

How To Embed Matplotlib In TKinter Window
How To Embed Matplotlib In TKinter Window

 

 

 

 

Also you can watch the complete video for this article

(Visited 2,972 times, 15 visits today)
Share via
Copy link
Powered by Social Snap