'canvas.show' was deprecated in version 2.2. Message says to use 'canvas.draw' instead. Worked for me but the navigation icons are not in color as on your screen.
Using Python 3.9...I had to change the line "from matplotlib.backends.backend_tkagg import (FigureCanvasTkAgg, NavigationToolbar2TkAgg)" to "...NavigationToolbar2Tk)" and I needed to remove the canvas.show in the PageThree class. But it seems to work great now! Great tutorial!
I manage to figure out by myself that ("from matplotlib.backends.backend_tkagg import (FigureCanvasTkAgg, NavigationToolbar2TkAgg)" to "...NavigationToolbar2Tk)") but i doubt that only by removing the canvas.show() would solve the problem!! Hahahahaha, thank you, sir!!
Thanks for these tutorials. Ive been battling for weeks trying to find the answer to switching frames for my menu window. I agree, online content is limited. And have found that ChatGPT isnt that smart as it cant reason. Thanks again, finally I can make ptogress! Will be checking the rest after I redisgned my menu.
To anybody having trouble with this make sure you use pip and install everything that it says you're missing. Ex cmd: "pip install six" will install the module "six". If you have problems with NumPy, google Visual C++ 9.0 for python and install it. Then run on the command line "python -m pip install numpy". Spent hours working on this and finally got it to work after this.
I had a lot of trouble because I'm using Anaconda(if you are having trouble before this some googling should solve this quickly).I am using Visual Studio and python 3.5. The way to get this working in Visual Studio is to go to View\Other Windows\Python Environments, in whichever Anaconda and Python version you are using, go to pip and uninstall both pillow and matplotlib. You then use pip to reinstall (pillow then matplotlib) and everything should be fine. If you are not using Visual Studio then you need to need to uninstall the same programs as I just mentioned. I believe it is a known bug and Anaconda is trying to fix it.
On my Python version, 3.9.7, it did not like the "NavigationToolbar2TkAgg". Instead, it accepted "NavigationToolbar2Tk". Just a heads up if anyone now is having the same problem
Hi there sentdex! firstly, I'd like to echo the positive comments for covering this subject - it's a great help! Secondly, I'm following this example on my raspberry pi and have encountered the following error message specific to the use of matplotlib:"ImportError: cannot import name '_tkagg'"The area of code it refers to is in the import lines of code: "from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2TkAgg"I've got all the code typed as per your example and the pi is fully up to date. Any ideas would be great fully received!Again, the lessons are great and a good source of knowledge!
I've been watching your tutorials with great interest so far (thank you for your work btw). But there is something that has always bothered me and didn't manage to find anything about it on the net mainly: Why is """self""" the second argument in some of your instances of module classes? Shouldn't it be the first argument as a convention? In which situation does it appear as a second parameter? I tried switching the positions but got errors so a little help would be really appreciated in understanding this :).
I'm not an expert but u should pay atentio to the object. In the case of the creation FigureCanvasTkAgg if u look in the documentation the arguments should be first the figure an then the master window, in this case the object-self. goo.gl/AU7tv1
Hey, thanks for that tutorial! I have a question: how can I delete or overwrite this canvas object? I want to plot the data from different csv files. It works for the first dataset, but the second dataset is plotted below the first one and also very ugly and without any interactive features. For the third dataset, nothings happens.
If you get this error: from matplotlib.backends import _tkagg ImportError: DLL load failed: The specified module could not be found. A temporary fix is to add import matplotlib.pylab as pylab before matplotlib.use("TkAgg")
7 лет назад+1
Yup, that did the trick! thank you so much,, and sentdex for the videos. can you explan why it worked tho? thx again
Hi, I'm following the video (actually the playlist) and I have the following problem: when I press save, I get this error: master=self.canvas.manager.window, AttributeError: 'FigureCanvasTkAgg' object has no attribute 'manager' Can you help me to solve it?
instead of adding classes to frames list it would be nice to make that dynamic by inspecting sys.modules or globals() and selecting classes that endwith "Page" or something like that.
I am following along in the tutorial and am wondering if this app can be made to be open ended to grab a variety of live data sets, such as Corona virus stats etc?
Hello, I took your lessons on Tkinter and Python and tried to run the same code from the tutorials with the simple graph from matplotlib (teh exact same code in the above video). But when I run the program I get this error tried to search on google but could not find anything. The error says "Process finished with exit code -1073741819 (0xC0000005)" Please help.
Thank you for the tutorials. I was wondering if you know of a way that you can select a region on the plot, and when you select that region, store the x and y boundaries of the selected region. For example, on your plot your x axis goes from 1 - 8 and your y axis goes from 1 - 9. If you selected the region x[4:7] and y[2:6], then the values x1=4, x2=7, y1=2, and y2=6 are stored, and can be used else where in the program.
Excellent tutorial as always! I have a question regarding if it's the normal way i python to have all the classes in the same file (Yes, i'm from the Java-family)?
NICE! But what about if you plot it into Negative axis (x and y coordinates) ? The plotmatlib origin only shows positive axis of x and y from (0,0) ...
Hello ! i am working on my professional project . I am creating a tkinter GUI which consist of importing data and ploting graphs on it like histogrms, QQ and PP plots. Could someone help me
As others I am also getting Tcl:error, while using Anaconda, I want to ask rather than using TkAgg as backend can I use Qt4Agg as backend and solve the above problem. I am pretty young in python world and if not a tutorial video some demo code or some documentation how to do it, would be pretty helpful for me. thanks in advance
Hey Sentdex thanks for a good tutorial, I've been adapting your code to create a live serial plotter from an arduino any tips/links you can share to make this run smoothly?
I have a data frame which gets created when a file is chose by the user. I am trying to output that data frame on a tkinter window but I am not able to do it. Is there anyway to do that? Thanks to your video I can show the plots on the Tkinter window but not that data frame. Any help will be appreciated. Thank you so much.
Not sure why my Matplotlib toolbar is bare bones black and white but yours on the tutorial is got some colors. Could it be the style that's being assigned?
What's the difference between get_tk_widget() and _tkcanvas at 13:30 and why do you even call up "canvas." twice? Seems to work for me either way, was expecting an error somewhere when trying to switch these around...
Hi.. Instead of using the pack method, how do i go about using the grid method? I've been giving it a try and have no problems with e buttons. But the matplotlib graph won't display.
I got the ImportError: 'Cannot load backend 'TkAgg' which requires the 'tk' interactive framework, as 'qt5' is currently running' if I call matplotlib.use('TkAgg'). The backend TkAgg cannot be found or something. Any idea how to fix this?
Get same, I have Anaconda installed with Python 3.7.6 matplotlib 3.1.3, some folks are describing "NavigationToolbar2TkAgg is deprecated. Use NavigationToolbar2Tk instead" Does that have anything to do with the error? I am a real newbie, I just converted one of my Matlab simulations to python witch works great, I just can't figure out the GUI.
Hi Harison, I am using Spyder(Anaconda package, Python 3.5) to run your tutorial. It works fine, untill I add the canvas show part. Then I get this "it seems the kernel died unexpectedly. Use 'Restart kernel' to continue using this console.". Can you please help.
+Roland Blok Hi Roland, I didn't waste time anymore with Spyder, rather started with WinPython plain simple and very easy to use. I would recommend try using WinPython.
line 107, in __init__ canvas.show() AttributeError: 'FigureCanvasTkAgg' object has no attribute 'show' apakah canvas.show diabaikan saja? jika diabaikan, maka program dapat berjalan
Does anyone else finds the graph moving up a bit and got a bit cutoff on the top when navigating to some other pages and then clicking back to the graph page?
Hi sentdex, Can you please give me some steps on upgrading my matplotlib, I have a 1.3 version and running into errors when I try to install 2.0.0. I am working on Mac 10.12. Please let me know. I would really appreciate it. Thankyou
I'm not yet sure why this is happening, but I could not make the toolbar appear using your original code. I had to call canvas.get_tk_widget().pack() after making the toolbar. When I do that everything works as expected. canvas._tkcanvas.pack() doesn't seem to work although maybe the toolbar is being put behind the figure. I am using matplotlib 1.5.0 and python 3.5.
It seems, there were changes in the usage. For the recent version of all packages the following worked for me to put the navigation bar on top: canvas.get_tk_widget().pack(side=tk.BOTTOM, fill=tk.BOTH, expand=True) for canvas and toolbar.pack(side=tk.TOP, fill=tk.BOTH, expand=True) for the toolbar part.
I know this video is 6 years old, but here goes nothing. Is there anyone who can tell me how I can add 2 graphs in one figure. To specify I want to be able to plot a quadratic equation, and the y=0 line to solve quadratic equations visually. How would I add these two plots to 1 figure so they share x and y axis?
@sentdex I am using spyder IDE from Anaconda envirmont. I am getting following error :-> " Cannot load backend 'TkAgg' which requires the 'tk' interactive framework, as 'qt5' is currently running " Can you please suggest me the solution. thanks in advance.
ImportError: cannot import name 'NavigationToolbar2TkAgg' from 'matplotlib.backends.backend_tkagg' (/home/recki/.local/lib/python3.8/site-packages/matplotlib/backends/backend_tkagg.py)
First, you are cool thank you. Second, I need your help. I have CSV file which includes X, Y, Z axis and 7 elements concentrations Au, As etc. I need to visualize data like building histogram, mean, median for every element, basic statistic. I want to write code for one and automatically go from first element to the last element, like column by column. I guess I have to use for loop. But not sure. How to do this? Please help,.
Again, issues with Pack and Grid. I have been following along, trying to modify the code for grid() and not pack() and run into this _tkinter.TclError: cannot use geometry manager pack inside .!frame.!pagethree which already has slaves managed by grid canvas = FigureCanvasTkAgg(f, self) # canvas.show() canvas.draw() canvas.get_tk_widget().grid(row=2, column=0, padx=5, pady=5) toolbar = NavigationToolbar2Tk(canvas, self) toolbar.update() # canvas._tkcanvas.grid(row=4, column=0, padx=0, pady=0) So back to pack() it is. By the way, sorry for being a Jerk. You've put SOOOOOO much work into these. I do appreciate it.
In your matplotlib tutorials you always use "import matplotlib.pyplot as plt", why are you using "from matplotlib.figure import figure"? What is the difference?
NavigationToolbar2TkAgg works but throws and error. According to StackOverflow, Matplotlib now want NavicationToolbar2Tk with the Agg. I tried it and it runs without the error. Here's the link if interested: stackoverflow.com/questions/50330320/what-to-use-instead-of-navigationtoolbar2tkagg
I've banged my head for 5 hours trying to fix an issue with the backends part of matplotlib. It turns out matplotlib requires a library called PyGTK, which requires pyGobject, which requires pyCairo. I'm having this weird issue installing pyCairo in particular where it says that include file called 'cairo.h' is missing. The command prompt (I'm on Windows 10 default command prompt without using admin mode) then proceeds to spew red error text in my face. Anyone know how I get past that issue? I'm using Python 3.6 BTW.
I have windows 10 64bit laptop and i use python 3.4 I use pycharm compiler and when i manually dl the 64bit version from site and try to install it,it says "python 3.4 not found in your system" and i try to install 32bit version it finds the python34 folder and installs it.But it doesnt work. Pycharm says,cant install matploplib because unable to find vcvarsall.bat. But i have c++ 2005,2008,2010,2012,2013 How come there is no vcvarshall.bat ?
show() = AttributeError: 'FigureCanvasTkAgg' object has no attribute 'show' draw() = AttributeError: 'NoneType' object has no attribute 'update_idletasks' what a hack can be used?
I'm getting a trackback error on "from matpfrom matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2TkAgg" I get an "ImportError: cannot import name 'NavigationToolbar2TkAgg' from 'matplotlib.backends.backend_tkagg'" I can't find any solution elsewhere. Anyone else getting the same issue? Import matplotlib - works from matplotlib import style - works
WORKING CODE: from matpfrom matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2Tk instead of from matpfrom matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2TkAgg
#SOS please help....i get a error "matplotlib.use("TkAgg") AttributeError: 'module' object has no attribute 'use' What should i do...i've watched your attribute tutorial but i still cant find the problem... Thx
Laissez - faire but when i enter it in pycharm it gives me Traceback (most recent call last): File "C:/Users/Robert/PycharmProjects/untitled4/python configure-ng.py", line 2, in print(matplotlib.__file__) AttributeError: 'module' object has no attribute '__file__'
I was trying to integrate your matplotlib code into my existing Python/tkinter program which uses stringvar(). My code had worked ok, buttons and labels etc, before I integrated your code but after integrating your code, stringvar() wasn't recognized and sadly I will have to look for another way to include a matplotlib graph into my code.
John Baker I just now discovered that I don't have to use StringVar for the labels on my GUI. So I will go back to try to use your matplotlib code in my GUI.
John Baker I can use StringVar() by including "from tkinter import *" 1) But am getting Python crashing with the canvas.show() command. My code is a little different from the sendex code. I want everything on one page so am using an upper Frame for some data entry and data display and a second (lower) Frame for the graph. All works ok until I do the canvas.show() command. Any idea why canvas.show() crashes Python? 2) Another problem is that I get an extra window, the tk window. My main window is named "My Window." How to get rid of the tk window?
John Baker Now trying sendex code from pythonprogramming.net/how-to-embed-matplotlib-graph-tkinter-gui/ I see it crashes Python too! Not a good sign. I'm using Anaconda, so that may be the problem.
John Baker Ok, I got your Python/tkinter/matplotlib code to run. Apparently the problem was with Anaconda. So getting away from Anaconda, I downloaded and installed Python 32 bit version from the Python website although my PC is a 64 bit Win7. I installed the 32 bit Python because of the next install from the cs.wpi.edu website: I got and installed Matplotlib, Numpy etc from web.cs.wpi.edu/~cs1004/a14/Resources/. Then I had another problem with the font cache which I solved with info from askubuntu.com/questions/578129/plotting-with-matplotlib-in-python-3-pylab-tkinter-and-qt-fontmanager-errors, although I'm using Win7. Then finally I was able to get my own code running to show your simple graph but the graph shows up in the xtra tk window, and I really want it to show in the lower Frame in my code. So I have more work to do but it looks much more promising. Hopefully this info will be helpful to others.
John Baker Got my code all working, a little different from Sentdex's in that my GUI with graph is all on a single page. Check out my blog at johnbakeree.blogspot.com/ Thanks Sentdex!
HELP! My Python comes up with an error when I type "from matplotlib import styles" !: Traceback (most recent call last): File "", line 1, in from matplotlib import styles ImportError: cannot import name 'styles' Please Help Me!
Thanks for this! You're so kind to do this tutorial for anyone to ask; no charge! Thank you so much! I've been going around the internet for ages reinstalling and uninstalling modules. I'm such an idiot! You've made my day! :D
Following along, at the end of this video the code wont run. The TclError error I get points (literally with a -->) to the line of code that says canvas.show() after not being able to figure it out what typo I must have I borrowed your written code from pythonprogramming.net, and it throws the same error. The error also points to some lines in draw() from backend_tkagg.py and blit() from tkagg.py I'm using python 3.4.1 from anaconda, Any idea whats wrong with my interpreter?
I am guessing the problem is with anaconda having their own "versions" of matplotlib and maybe some different locations of matplotlib and the necessary file. Try using just a straight python 3.4 IDLE. You should be able to have both on your computer. You might also contact them or maybe search to see if others have had this issue when changing the backend of matplotlib's canvas.
Couldn't find other people with similar issues, I'm sure because the error is to vague. I installed 3.4 IDLE to try a clean version but ran out of time before installing matplotlib, hopefully then it works, though it seams troubling that such a popular/common package like anaconda would have something broken which is, I perhaps wrongly think, a pretty common use of matplotlib.
Nicholas Johnson I've never been a fan of having custom installations of python for this very reason. This specific problem is likely very uncommon, but the conglomeration of problems and minor differences between having a custom environment versus the default is pretty common.
As always i have problems "AttributeError: 'NavigationToolbar2TkAgg' object has no attribute 'upadte' " my code: toolbar = NavigationToolbar2TkAgg(canvas, self) toolbar.upadte()
'canvas.show' was deprecated in version 2.2. Message says to use 'canvas.draw' instead. Worked for me but the navigation icons are not in color as on your screen.
*_canvas.draw()_* thanks saved me some grief...
Thanks for this! I was about to give up on matplotlib.
I had this issue...no errors now but the graph isnt plotting!
Thank you sir.
This time I did not surf in the internet. I straight came to the comments.... Thanks a lot!!
Using Python 3.9...I had to change the line "from matplotlib.backends.backend_tkagg import (FigureCanvasTkAgg, NavigationToolbar2TkAgg)" to "...NavigationToolbar2Tk)" and I needed to remove the canvas.show in the PageThree class. But it seems to work great now! Great tutorial!
thank you so much Paul i had this problem too this helped!!
Thanks man i was having trouble
Muchas gracias!!! Tenia el mismo problema :)
I manage to figure out by myself that ("from matplotlib.backends.backend_tkagg import (FigureCanvasTkAgg, NavigationToolbar2TkAgg)" to "...NavigationToolbar2Tk)") but i doubt that only by removing the canvas.show() would solve the problem!! Hahahahaha, thank you, sir!!
thanks this helped me
14:55
-"Why am I failing?"
I relate to this on a spiritual level
Thanks for these tutorials. Ive been battling for weeks trying to find the answer to switching frames for my menu window.
I agree, online content is limited. And have found that ChatGPT isnt that smart as it cant reason.
Thanks again, finally I can make ptogress! Will be checking the rest after I redisgned my menu.
To anybody having trouble with this make sure you use pip and install everything that it says you're missing. Ex cmd: "pip install six" will install the module "six". If you have problems with NumPy, google Visual C++ 9.0 for python and install it. Then run on the command line "python -m pip install numpy".
Spent hours working on this and finally got it to work after this.
I loved the struggle, such the real experience of programming
NavigationToolbar2Tk use this
instead of NavigationToolbar2TkAgg
whenever i stuck in any problem i follow your tutorials and get solution .
I had a lot of trouble because I'm using Anaconda(if you are having trouble before this some googling should solve this quickly).I am using Visual Studio and python 3.5. The way to get this working in Visual Studio is to go to View\Other Windows\Python Environments, in whichever Anaconda and Python version you are using, go to pip and uninstall both pillow and matplotlib. You then use pip to reinstall (pillow then matplotlib) and everything should be fine. If you are not using Visual Studio then you need to need to uninstall the same programs as I just mentioned. I believe it is a known bug and Anaconda is trying to fix it.
+Mr. Buffoonery Thanks so much for the tip, I just followed your advice and it fixed the problem!
+Mr. Buffoonery Awesome.. Thanks.. I had the same issue and spent hours trying to fix it..
+Mr. Buffoonery Thank you. This got it to work for me.
Thanks, man saved me a good few hours (or days even!) too. These comments are really appreciated.
Thanks. It works now.
On my Python version, 3.9.7, it did not like the "NavigationToolbar2TkAgg". Instead, it accepted "NavigationToolbar2Tk". Just a heads up if anyone now is having the same problem
Hi there sentdex! firstly, I'd like to echo the positive comments for covering this subject - it's a great help! Secondly, I'm following this example on my raspberry pi and have encountered the following error message specific to the use of matplotlib:"ImportError: cannot import name '_tkagg'"The area of code it refers to is in the import lines of code: "from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2TkAgg"I've got all the code typed as per your example and the pi is fully up to date. Any ideas would be great fully received!Again, the lessons are great and a good source of knowledge!
Using any button on the toolbar gives this: AttributeError: 'FigureCanvasTkAgg' object has no attribute 'manager'
Attempting to install matplotlib. That's 3 hours of my life I will never get back.
+GibsnRage only to discover.. I have python installed as 32-bit.. Seems best I just start fresh installing this huge library of dependencies.. ;_;
Lol.
Awesome series!
Pls make sure, to continue to the end ans if possible upload the videos more frequently.
I've been watching your tutorials with great interest so far (thank you for your work btw).
But there is something that has always bothered me and didn't manage to find anything about it on the net mainly: Why is """self""" the second argument in some of your instances of module classes?
Shouldn't it be the first argument as a convention?
In which situation does it appear as a second parameter?
I tried switching the positions but got errors so a little help would be really appreciated in understanding this :).
I'm not an expert but u should pay atentio to the object. In the case of the creation FigureCanvasTkAgg if u look in the documentation the arguments should be first the figure an then the master window, in this case the object-self. goo.gl/AU7tv1
Hey, thanks for that tutorial! I have a question: how can I delete or overwrite this canvas object? I want to plot the data from different csv files. It works for the first dataset, but the second dataset is plotted below the first one and also very ugly and without any interactive features. For the third dataset, nothings happens.
If you get this error:
from matplotlib.backends import _tkagg
ImportError: DLL load failed: The specified module could not be found.
A temporary fix is to add
import matplotlib.pylab as pylab
before matplotlib.use("TkAgg")
Yup, that did the trick! thank you so much,, and sentdex for the videos.
can you explan why it worked tho? thx again
Iv come here from the main website as I had an inkling there may be a solution to this problem in the 'youtube comments' thank you for the fix
Hi, I'm following the video (actually the playlist) and I have the following problem: when I press save, I get this error:
master=self.canvas.manager.window,
AttributeError: 'FigureCanvasTkAgg' object has no attribute 'manager'
Can you help me to solve it?
tkinter has a built in task scheduler that allows u to use the mainloop of the program to preform updates to the gui
instead of adding classes to frames list it would be nice to make that dynamic by inspecting sys.modules or globals() and selecting classes that endwith "Page" or something like that.
Boa ideia! Chegou a implementar isso?
@@bauerw não
how could I use grid in this example especially for the plot and the toolbar?
I am following along in the tutorial and am wondering if this app can be made to be open ended to grab a variety of live data sets, such as Corona virus stats etc?
Hello, I took your lessons on Tkinter and Python and tried to run the same code from the tutorials with the simple graph from matplotlib (teh exact same code in the above video). But when I run the program I get this error tried to search on google but could not find anything. The error says "Process finished with exit code -1073741819 (0xC0000005)" Please help.
Try reinstalling matplotlib
Thank you for the tutorials. I was wondering if you know of a way that you can select a region on the plot, and when you select that region, store the x and y boundaries of the selected region. For example, on your plot your x axis goes from 1 - 8 and your y axis goes from 1 - 9. If you selected the region x[4:7] and y[2:6], then the values x1=4, x2=7, y1=2, and y2=6 are stored, and can be used else where in the program.
The best python tutorials!
Hello, what is the controller "go to page" function?
Excellent tutorial as always! I have a question regarding if it's the normal way i python to have all the classes in the same file (Yes, i'm from the Java-family)?
NICE! But what about if you plot it into Negative axis (x and y coordinates) ? The plotmatlib origin only shows positive axis of x and y from (0,0) ...
In tkinter you can refresh frames by changing values of some functions
Hello ! i am working on my professional project . I am creating a tkinter GUI which consist of importing data and ploting graphs on it like histogrms, QQ and PP plots. Could someone help me
As others I am also getting Tcl:error, while using Anaconda, I want to ask rather than using TkAgg as backend can I use Qt4Agg as backend and solve the above problem. I am pretty young in python world and if not a tutorial video some demo code or some documentation how to do it, would be pretty helpful for me. thanks in advance
Is it possible to instead add background images and entry fields in this code? If so i don't know how and i would like to do it.
16:00 haha that was very natural
Hey Sentdex thanks for a good tutorial, I've been adapting your code to create a live serial plotter from an arduino any tips/links you can share to make this run smoothly?
I have a data frame which gets created when a file is chose by the user. I am trying to output that data frame on a tkinter window but I am not able to do it. Is there anyway to do that?
Thanks to your video I can show the plots on the Tkinter window but not that data frame. Any help will be appreciated. Thank you so much.
Hi sentdex, how can i change color of graph or set background graph transparent or dark mode. Thank you
Not sure why my Matplotlib toolbar is bare bones black and white but yours on the tutorial is got some colors. Could it be the style that's being assigned?
Great tutorial! How can I add a title and axis labels to the graph?
Are there conflicts using grid and toolbar instead of pack?
What's the difference between get_tk_widget() and _tkcanvas at 13:30 and why do you even call up "canvas." twice?
Seems to work for me either way, was expecting an error somewhere when trying to switch these around...
Hi.. Instead of using the pack method, how do i go about using the grid method? I've been giving it a try and have no problems with e buttons. But the matplotlib graph won't display.
I got the ImportError: 'Cannot load backend 'TkAgg' which requires the 'tk' interactive framework, as 'qt5' is currently running' if I call matplotlib.use('TkAgg'). The backend TkAgg cannot be found or something. Any idea how to fix this?
I am getting same error . May I know how did you fix it ??
Get same, I have Anaconda installed with Python 3.7.6 matplotlib 3.1.3, some folks are describing "NavigationToolbar2TkAgg is deprecated. Use NavigationToolbar2Tk instead" Does that have anything to do with the error? I am a real newbie, I just converted one of my Matlab simulations to python witch works great, I just can't figure out the GUI.
Hi Harison, I am using Spyder(Anaconda package, Python 3.5) to run your tutorial. It works fine, untill I add the canvas show part. Then I get this "it seems the kernel died unexpectedly. Use 'Restart kernel' to continue using this console.". Can you please help.
+Bikash Debnath i have exactly the same probelm. Python crashes on show function...
+Roland Blok
Hi Roland, I didn't waste time anymore with Spyder, rather started with WinPython plain simple and very easy to use. I would recommend try using WinPython.
+Bikash Debnath tnx. That actually works.
+Bikash Debnath See Mr Bufoonery's comment below.
hi so how can i upload a geodatabase to read it and show it and apply tools in it in my gui
Hello, is it possible to get the data analysis information in the entry widget with tkinter?
ok I get that but then how do you create the same graph you created using information from the user input
great tutorials!! keep up the good work..
I have a question though, Instead of a Matplotlib graph, how to add or display an Image to the Tinter GUI?
Here's a basic example of images:
pythonprogramming.net/tkinter-adding-text-images/
How do I put strings instead of numbers at the x values, it won't accept string.
How can I change the size of the GUI on all of the pages, without the graph as I want to make a login page with numerous pages?
tkagg seems to not be working in windows 10
line 107, in __init__
canvas.show()
AttributeError: 'FigureCanvasTkAgg' object has no attribute 'show'
apakah canvas.show diabaikan saja?
jika diabaikan, maka program dapat berjalan
can I change the background image of the graph?
Does anyone else finds the graph moving up a bit and got a bit cutoff on the top when navigating to some other pages and then clicking back to the graph page?
Mil gracias amigo..tu vídeo es genial!
AttributeError: 'FigureCanvasTkAgg' object has no attribute 'manager' when using the Toolbar. How can we use e.g. the 'save' Button?
I want to add graph to a pdf . I am using Anaconda Navigator and reportlab module to make pdf and in that i want to add graph
i may be having same issue except when ig et the 64 bit installer it tells me i dont have pythin 3.4 installed . .when i do
Hi Sentdex, Can you tell, how to change axis spacing to 'log' in tk-integrated plots ?
Hi sentdex, Can you please give me some steps on upgrading my matplotlib, I have a 1.3 version and running into errors when I try to install 2.0.0. I am working on Mac 10.12. Please let me know. I would really appreciate it.
Thankyou
I'm not yet sure why this is happening, but I could not make the toolbar appear using your original code. I had to call canvas.get_tk_widget().pack() after making the toolbar. When I do that everything works as expected. canvas._tkcanvas.pack() doesn't seem to work although maybe the toolbar is being put behind the figure. I am using matplotlib 1.5.0 and python 3.5.
yes thanks for this. I had the same problem :)
It seems, there were changes in the usage. For the recent version of all packages the following worked for me to put the navigation bar on top:
canvas.get_tk_widget().pack(side=tk.BOTTOM, fill=tk.BOTH, expand=True)
for canvas and
toolbar.pack(side=tk.TOP, fill=tk.BOTH, expand=True)
for the toolbar part.
Hi sentdex, I was wondering if you could tell me how to convert this into python 2.7?
I know this video is 6 years old, but here goes nothing.
Is there anyone who can tell me how I can add 2 graphs in one figure. To specify I want to be able to plot a quadratic equation, and the y=0 line to solve quadratic equations visually.
How would I add these two plots to 1 figure so they share x and y axis?
This program shows me this error 'matplotlib' is not defined, could you help me
thanks for this amazing video bro
@sentdex I am using spyder IDE from Anaconda envirmont. I am getting following error :-> " Cannot load backend 'TkAgg' which requires the 'tk' interactive framework, as 'qt5' is currently running " Can you please suggest me the solution. thanks in advance.
update : it runs without error via conda command prompt. But doesnt work with spyder builtin console.
can you use Tkinter and matplotlib in Raspberry Pi, To graph signals in real-time?
How do i add some themes to my application to make it beautiful ?Plz help!!!
I have the same problem with Anaconda on Win7. TkAgg backend don't work! qt4Agg seems to work better with Matplotlib...
Thanks for video. but how can I get date vs data graph here?
Instead of show() use draw()
ImportError: cannot import name 'NavigationToolbar2TkAgg' from 'matplotlib.backends.backend_tkagg' (/home/recki/.local/lib/python3.8/site-packages/matplotlib/backends/backend_tkagg.py)
First, you are cool thank you.
Second, I need your help. I have CSV file which includes X, Y, Z axis and 7 elements concentrations Au, As etc. I need to visualize data like building histogram, mean, median for every element, basic statistic. I want to write code for one and automatically go from first element to the last element, like column by column. I guess I have to use for loop. But not sure. How to do this? Please help,.
14:55 in 1.5x speed "NO" sounds extra cute~~
"I can't win today guys" it's the sentece that I more reapet when I 'm coding.
Is this code available on any repository please
Again, issues with Pack and Grid. I have been following along, trying to modify the code for grid() and not pack() and run into this
_tkinter.TclError: cannot use geometry manager pack inside .!frame.!pagethree which already has slaves managed by grid
canvas = FigureCanvasTkAgg(f, self)
# canvas.show()
canvas.draw()
canvas.get_tk_widget().grid(row=2, column=0, padx=5, pady=5)
toolbar = NavigationToolbar2Tk(canvas, self)
toolbar.update()
# canvas._tkcanvas.grid(row=4, column=0, padx=0, pady=0)
So back to pack() it is.
By the way, sorry for being a Jerk. You've put SOOOOOO much work into these. I do appreciate it.
In your matplotlib tutorials you always use "import matplotlib.pyplot as plt", why are you using "from matplotlib.figure import figure"? What is the difference?
who knows...?
NavigationToolbar2TkAgg works but throws and error. According to StackOverflow, Matplotlib now want NavicationToolbar2Tk with the Agg. I tried it and it runs without the error. Here's the link if interested: stackoverflow.com/questions/50330320/what-to-use-instead-of-navigationtoolbar2tkagg
would you be so kind and paste the code in you describtion?
I've banged my head for 5 hours trying to fix an issue with the backends part of matplotlib. It turns out matplotlib requires a library called PyGTK, which requires pyGobject, which requires pyCairo. I'm having this weird issue installing pyCairo in particular where it says that include file called 'cairo.h' is missing. The command prompt (I'm on Windows 10 default command prompt without using admin mode) then proceeds to spew red error text in my face. Anyone know how I get past that issue? I'm using Python 3.6 BTW.
This is how i was able to close plot:
def on_closing():
quit()
app = SeaofBTCapp()
app.protocol("WM_DELETE_WINDOW", on_closing)
app.mainloop()
My Graph is a pizza Style (axl pie) so i am having problems with this, can someone help?
I have windows 10 64bit laptop and i use python 3.4
I use pycharm compiler and when i manually dl the 64bit version from site and try to install it,it says "python 3.4 not found in your system" and i try to install 32bit version it finds the python34 folder and installs it.But it doesnt work.
Pycharm says,cant install matploplib because unable to find vcvarsall.bat.
But i have c++ 2005,2008,2010,2012,2013
How come there is no vcvarshall.bat ?
and what does that mean:
import numpy as np
ImportError: No module named 'numpy'
i tried it but there is no module as numpy i guess :/
+Curious Guy means you need to install numpy. How to do this: pythonprogramming.net/using-pip-install-for-python-modules/
The graph isn't showing. Even if i use canvas.draw() and FigureCanvasTk
I change FigureCanvasTk by FigureCanvasTkAgg to fixed it
good job
show() = AttributeError: 'FigureCanvasTkAgg' object has no attribute 'show'
draw() = AttributeError: 'NoneType' object has no attribute 'update_idletasks'
what a hack can be used?
You could replace cavas.show() to canvas.draw(). It worked for me
@@andersoncanteli Thank you that was very helpful
canvas.show() doesn't work anymore, canvas.draw() does instead.
Im getting an errror TclError: wrong # args: should be "wm iconbitmap window ?bitmap?"
Python 3.7
I'm getting a trackback error on "from matpfrom matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2TkAgg"
I get an "ImportError: cannot import name 'NavigationToolbar2TkAgg' from 'matplotlib.backends.backend_tkagg'"
I can't find any solution elsewhere.
Anyone else getting the same issue?
Import matplotlib - works
from matplotlib import style - works
WORKING CODE:
from matpfrom matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2Tk
instead of
from matpfrom matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2TkAgg
If I write "canvas._tkcanvas.pack(side=tk.BOTTOM, fill=tk.BOTH, expand = True)",
then is the toolbar on the top, but why? I think it is curious. :D
+Erik.R maybe he didn't save before he tested it?
#SOS please help....i get a error "matplotlib.use("TkAgg")
AttributeError: 'module' object has no attribute 'use'
What should i do...i've watched your attribute tutorial but i still cant find the problem...
Thx
Laissez - faire odd. Do you have anything in your directory called matplotlib?
sentdex No i don't
Laissez - faire try doing:
import matplotlib
print(matplotlib.__file__)
What comes out?
Copy and paste your full code here too, let's look at that.
sentdex Traceback (most recent call last):
File "", line 1, in
print(matplotlib.__file__)
AttributeError: 'module' object has no attribute '__file__'
Laissez - faire but when i enter it in pycharm it gives me
Traceback (most recent call last):
File "C:/Users/Robert/PycharmProjects/untitled4/python configure-ng.py", line 2, in
print(matplotlib.__file__)
AttributeError: 'module' object has no attribute '__file__'
I was trying to integrate your matplotlib code into my existing Python/tkinter program which uses stringvar(). My code had worked ok, buttons and labels etc, before I integrated your code but after integrating your code, stringvar() wasn't recognized and sadly I will have to look for another way to include a matplotlib graph into my code.
John Baker I just now discovered that I don't have to use StringVar for the labels on my GUI. So I will go back to try to use your matplotlib code in my GUI.
John Baker I can use StringVar() by including "from tkinter import *"
1) But am getting Python crashing with the canvas.show() command. My code is a little different from the sendex code. I want everything on one page so am using an upper Frame for some data entry and data display and a second (lower) Frame for the graph. All works ok until I do the canvas.show() command. Any idea why canvas.show() crashes Python?
2) Another problem is that I get an extra window, the tk window. My main window is named "My Window." How to get rid of the tk window?
John Baker Now trying sendex code from
pythonprogramming.net/how-to-embed-matplotlib-graph-tkinter-gui/
I see it crashes Python too! Not a good sign. I'm using Anaconda, so that may be the problem.
John Baker Ok, I got your Python/tkinter/matplotlib code to run. Apparently the problem was with Anaconda. So getting away from Anaconda, I downloaded and installed Python 32 bit version from the Python website although my PC is a 64 bit Win7. I installed the 32 bit Python because of the next install from the cs.wpi.edu website: I got and installed Matplotlib, Numpy etc from web.cs.wpi.edu/~cs1004/a14/Resources/. Then I had another problem with the font cache which I solved with info from askubuntu.com/questions/578129/plotting-with-matplotlib-in-python-3-pylab-tkinter-and-qt-fontmanager-errors, although I'm using Win7. Then finally I was able to get my own code running to show your simple graph but the graph shows up in the xtra tk window, and I really want it to show in the lower Frame in my code. So I have more work to do but it looks much more promising. Hopefully this info will be helpful to others.
John Baker Got my code all working, a little different from Sentdex's in that my GUI with graph is all on a single page. Check out my blog at johnbakeree.blogspot.com/
Thanks Sentdex!
why my icons are black =(
HELP!
My Python comes up with an error when I type "from matplotlib import styles" !:
Traceback (most recent call last):
File "", line 1, in
from matplotlib import styles
ImportError: cannot import name 'styles'
Please Help Me!
+Alex Highland it's not styles, it's just style, singular.
+sentdex Thank you so much!
Thanks for this! You're so kind to do this tutorial for anyone to ask; no charge! Thank you so much! I've been going around the internet for ages reinstalling and uninstalling modules. I'm such an idiot! You've made my day! :D
Hello Sir.....
Awesome!
Would you look at that! That's exactly what I need :D
Following along, at the end of this video the code wont run. The TclError error I get points (literally with a -->) to the line of code that says canvas.show() after not being able to figure it out what typo I must have I borrowed your written code from pythonprogramming.net, and it throws the same error. The error also points to some lines in draw() from backend_tkagg.py and blit() from tkagg.py I'm using python 3.4.1 from anaconda, Any idea whats wrong with my interpreter?
I am guessing the problem is with anaconda having their own "versions" of matplotlib and maybe some different locations of matplotlib and the necessary file.
Try using just a straight python 3.4 IDLE. You should be able to have both on your computer. You might also contact them or maybe search to see if others have had this issue when changing the backend of matplotlib's canvas.
Couldn't find other people with similar issues, I'm sure because the error is to vague. I installed 3.4 IDLE to try a clean version but ran out of time before installing matplotlib, hopefully then it works, though it seams troubling that such a popular/common package like anaconda would have something broken which is, I perhaps wrongly think, a pretty common use of matplotlib.
Nicholas Johnson I've never been a fan of having custom installations of python for this very reason. This specific problem is likely very uncommon, but the conglomeration of problems and minor differences between having a custom environment versus the default is pretty common.
Got the exact same error as Nicholas and I'm also using python 3.4.1 from anaconda.
sentdex Getting the same error! Any solution?
i have a question, how do i put the toolbar on the top? lol jk
Great videos!
As always i have problems
"AttributeError: 'NavigationToolbar2TkAgg' object has no attribute 'upadte' "
my code:
toolbar = NavigationToolbar2TkAgg(canvas, self)
toolbar.upadte()
Adam Fatyga
What is: toolbar.upadte()? This is a typo.
AttributeError: 'FigureCanvasTkAgg' object has no attribute 'show'
use canvas.draw() instead of the show() command that is used in the video.