Skip to content

Matplotlib in Kivy updated to 12.4!

GitHub Repository

AI Transcript provided by KivyWhisper

Okay hello and welcome back to Kivy School. This is just going to be a follow-up video to my previous mapplotlib video. And it's just showing that as an update, things were closed, the issues got fixed. So I'll show you the GitHub issue that I created. There were just a couple bugs, this one, this one, and this one. They're all fixed. Actually for bug 3.2, this was not really a bug. It's because the zoom box, if you have like a very small zoom box, it just wouldn't run. And it wouldn't zoom in. But with a bigger zoom box, it will always zoom in. And MP007 said right here, for a bug, it's not a bug. The reason why your zoom box is not working is because your selection is lower than the min zoom attribute. And then you can change this attribute if you wanted. But they just set the min zoom to DP20 for a better user experience. So you could just have a smaller zoom box and then it'll work. So that's fixed.

Another thing to keep in mind is remember that this update is only available in mapplotlib 12.4. That's one thing to remember. And then we'll look at the examples that were previously bugged. And then here are the fixed examples. So let's just go like this. So we'll go to the bugged example right here that was bugged in the previous video. Now it's fixed in this video.

As you can see, it's a min max option. And then you will see here it shows the value when your cursor hovers on the graph. If you hover like this, it will show you values. And then pan still works. And zoom box works. You can zoom right here. And then hover, it will show you values. And double click to reset. Hover and it shows you values. And the next screen, same thing. You'll hover and it shows you all the values for the sinusoidal curve. And we can zoom in like this. It shows you values. Keep going. And again, this one's really nice because as you can see the box even is colored the same color as the graph. That's pretty neat. And you can still pan like this.

You can set the zoom box zoom right here. See the values. Next screen. Again, here you can see the values. And this one also, you can change the x-axis from seconds, minutes, hours. If you're still on zoom, the zooming will still work. And that's it for this example. I've shown you that it shows the value when your cursor hovers on the graph. And then I've shown you that you can change the axis. And then let's continue. So CD up, CD down. We're going to go to example 4. Python main. And then we're going to go to example 4. Python main. And the cursor on hover. And as you can see there's four graphs here. The axis from 0, 0, 0, 1, 1, 0, 1, 1. And as you can see it's also got the cursor on hover.

It will show you the value of the nearest graph. And also the color of the text box is the same as the color of the graph. And zoom box works as well, you can zoom in. It will still show you the values of the graph. And then you can change the text box. zoom in. We'll still show you the values of the graph. Zoom in. Let's zoom in here. And let's zoom in here. Red line, blue line. You can see it still works. Let's see if we can zoom out. No we can't. Okay, pretty neat. Then again here, we'll show you values. Let's pan it.

And as you can see these graphs are like correlated somehow, but moving this will move the other one. Then again we've seen this graph already, but as you can see here you can use the cursor to hover and then select values. That's pretty neat. Then with zoom box you can zoom here. And again the blue graph will change and the red graph will change. And then double click to reset everything. So pretty neat.

Go to the next example. So the CD up. CD example cursor on main. Again you can pan. There's no cursor, but actually this cursor is toggled. If you click here the cursor will be toggled. And here it's a different kind of cursor. It's something that selects the nearest data point. So you can see I'm trying to select something between this 8, 0 and this And this 2, 15. But if you try and select it, it will just not work because there's no data point in here. It's actually inferred between these two data points. So it just selects data points like this and it tells you the X and Y values, which is also pretty good. Okay that's good.

Then let's go to example hover. Here, very nice example. It says general hover touch behavior. Right now it's nothing right? Because you have to enable the cursor. The cursor is extra behavior. As you can see here, you can touch the points. It will tell you the values. Another thing is you can set hover vertical text hover with desktop behavior. So if you hover on the desktop, it will just select the point and it will show you text box with time and amplitude. Pretty nice. Another one is info hover with desktop behavior. Where again it's similar. It will just hover and it will also show you the graph. So here it says X is 1, Y is 2. It also tells you which line it is, which is line 1. And this one it tells you which line it is, line 2. So pretty neat. And zoom box also still works. A cursor like this will still change. Zoom box, zoom in. Zoom box, zoom in. Zoom box, you can zoom in. You can also pan. Pretty neat.

Okay, let's get up and then go to clear this. And we'll go to CD example. MPL cursors. And then here again we've seen these graphs before. You can also pan on it. But as you can see here, the cursor is already enabled on hover. Already enabled, already enabled. And you can see even in this pie chart, it will say 29.6%. 38.9%. And you can pan.

Apparently you can pan on this pie chart too and then take it away. Which is pretty funny. But yeah, don't do that. But for this one, you might want to go here and look at it a little bit. The zoom box is not here. But in any case, you can still pan this. You can still pan here. You can still pan this bar graph as well. Sorry, I just wanted to know if this was actually called a bar graph. But yeah, it is. It's called a bar graph or a bar chart.

And as you can see, you can turn on the cursor. And even maximize as well. So yeah, everything is working. So this is just an update example because I didn't want to leave on a bad note. NP007 actually had responded within a week. I just I did not see it on GitHub. And then he actually had to ping me on Discord. And then when I got pinged on Discord, I'm like, oh shoot, I should make an update video. That way people don't think that the Kivy mapplotlib widget is just not being updated. The correction, it is being updated.

And all the bugged examples, as you can see here, now they work. You just have to update to, again, you're going to update to at least mapplotlib 12.4. So everything works. The examples have been fixed. And yeah, this is just an update video. So I hope you guys enjoyed. I hope you guys could also use this mapplotlib widget.

I think it's really nice and it's really neat. And it's something good, especially with Kivy and with the way Python is used for a lot of data analysis, especially with mapplotlib. And yeah, I hope you learn something and you don't think that the mapplotlib widget is not being updated. It's totally being updated. And if you need something to display your graphs, please use it. Thanks for watching. Have a great day.

Article Error Reporting

Message @BadMetrics on the Kivy Discord.