Python matplotlib blit for axes or sides of a shape?

I am trying to update some of the graphs that I have in gui every time I go through a suitable procedure. In addition, these graphs are in a frame that can be changed, therefore, axes and labels, etc. Must be redrawn after resizing. I wonder if anyone knew how to update the sides of a figure using something like plot.figure.canvas.copy_from_bbox and blit . It seems that the background of the graphic display area (where the lines are drawn) is copied and blurred, and not on the sides of the graph or picture (where there are marks and ticks). I am trying to update my graphs with trial and error and reading the mpl documentation, but so far my jst code has become terribly complicated with things like self.this_plot.canvas_of_plot..etc.etc.. .plot.figure.canvas.copy_from_bbox ... which is probably too confusing. I know that my language may be turned off a bit, but I tried to read the matplotlb documentation, and the differences between the drawing, canvas, graphics, graphics, drawing. Customize etc. They start to dodge me. Therefore, my first and main question:

1 - How do you update ticks and tags around the matplotlib chart.

and secondly, since I would like to better understand that the answer to this question,

2 - What is the difference between plot, figure, canvas, etc. in relation to the area they cover in the graphical interface.

Thank you for help.

+5
source share
1 answer

All of this, of course, can be quite confusing at first!

To begin with, if you catch ticks, etc., it makes no sense to point to blits. Blitting is just a way to avoid re-drawing everything if only a few things change. If everything changes, it makes no sense to use strikers. Just redraw the plot.

Basically, you just want fig.canvas.draw() or plt.draw()

In any case, in order to answer your first question, in most cases you will not need to update them manually. If you change the axis boundaries, they will be updated. You run into problems because you only laugh inside the axes and not redraw the plot.

As for your second question, a good, detailed review is the Matplotlib User Guide .

In a nutshell, there are two separate layers. One of them concerns the grouping of things into those parts that you will worry about when plotting (for example, a figure, axes, axes, lines, etc.), and the other about rendering and drawing in general (canvas and rendering).

All you see on the matplotlib chart is Artist . (For example, text, line, axes, and even the figure itself.) The artist: a) knows how to draw himself, and b) may contain other artists.

In order for the artist to draw himself, he uses a renderer (a backend-specific module that you almost never touch directly) to draw t23> aka "(an abstraction around either a vector page or a pixel buffer). To draw everything on the figure, you call canvas.draw() .

Because artists can be groups of other artists, there is a hierarchy to things. Basically, something like this (obviously, this is changing):

 Figure Axes (0-many) (An axes is basically a plot) Axis (usually two) (x-axis and y-axis) ticks ticklabels axis label background patch title, if present anything you've plotted, eg Line2D's 

Hope this makes things clearer, anyway.

If you really want to use blitting to update tag labels, etc., you will need to capture and restore the full region, including them. This region is a little difficult to obtain, because it is not exactly known only after drawing (rendering text in matplotlib is more complicated than rendering other things due to latex support, etc.). You can do this, and I will be happy to give an example if this is really what you want, but this, as a rule, does not give an advantage in speed, but simply draws everything. (The exception is that you only update one subplot in a figure with a lot of subheadings.)

+16
source

Source: https://habr.com/ru/post/949060/


All Articles