Re-scaling x, y-axis on capture correct coordinate scale on mouse-over in matplotlib - python-3.x

I am rendering a data as shown below using cluster analysis.
As you can see that ports in the range of 0-200 are clubbed together. Is there a way to zoom in on the scale when I mouse over a coordinate and thereby redrawing that section of the graph again in a zoomed window. What i mean is that for the coordinates shown in blue circle, when I mouse over, I want the x, y axis redrawn for 0-10000 using a different scale so that overlapping circles move apart. Is it possible ?. I must confess I find matplotlib little challenging and my apologies if my question is little cryptic. thanks for the help!

Assuming youre using pyplot then this functionality is built right in to the pyplot output.
See the following from the matplotlib documentation.
The Zoom-to-rectangle button
Click this toolbar button to activate this mode. Put your mouse somewhere over an axes and press the left mouse button. Drag the mouse while holding the button to a new location and release. The axes view limits will be zoomed to the rectangle you have defined. There is also an experimental ‘zoom out to rectangle’ in this mode with the right button, which will place your entire axes in the region defined by the zoom out rectangle.
If you need to enable zoom to rectangle functionality without actually clicking then this will be possible by creating a transparent figure positioned in a location of your choice on your plot and then initiating a matplotlib event to be handled when the mouse hovers over this area. This functionality is not built in and will require customisation.
Detail relating to event handling on mouseover events can be found at this URL

Related

VTK: small cosy in a corner instead of the middle

Is it possible to have the vtkAxesActor small in a corner of the window?
Here is a image of what I currently got and what I would like to have. The colorful axes are the standard axesActor. But I would like the axes in a corner of the window and only there (bottom left in black). They shouldn't move around the window when the view is rotated. Only around their origin.
Is this possible? And if yes, how?
A possible solution is to put the vtkAxesActor into an orientation widget:
widget = vtk.vtkOrientationMarkerWidget()
widget.SetOrientationMarker(axisActor)
widget.SetInteractor(interactor)
widget.SetViewport(0, 0, size, size)
widget.InteractiveOff()
widget.EnabledOn()
The vtkAxesActor location is functional and it's location has a purpose. The anchor point of the AxesActor is the anchor point of the model. This provides context of where any transformations or translations would be calculated from.
Unfortunately the example of the axisActor in the corner you have proposed would only provide context of the orientation of the model and so not part of the standard options.

Using tk.Scrollbar to update images in tk.canvas

I developed a small tkinter GUI to display (and export) images stored in a proprietary format. I managed to load the data into a 3D numpy uint8 array. I want to display one slice of that 3D array in a tkinter.canvas. To do so I used ImageTk.PhotoImage.
Underneath the Canvas I inserted a tk.Scrollbar. My goal is to use that scrollbar to let the user actively "scroll" though the 3D Array. Basically when the slider is moved or any of the arrows is pressed the slice corresponding to the slider position should be displayed in the canvas.
Right now I have the issue that I don't understand how to set the range of the scrollbar to my z-Dimension and then how to bind the scrollbar events to the movement or arrow actions to update the canvas.
Right now I don't have example code since this is a more conceptual problem.
Could you point me in the right direction how to solve this?
Best TMC
edit: Photo
Tkinter Gui with Canvas and Scrollbar
The solution is to use tkinter.Scale instead of tkinter.Scrollbar . As a side note, the command within:
scale = tk.Scale(yourTkFrame, from_=min, to=max, orient='horizontal', command=doSomething)
passes two values to the function doSomething.
Using the Scale allows to use the scale.get() method to retrieve the position between min and max values. Those can then be used to set the image corresponding to the selected position on the slide.

How to not showing the coordinates (x,y) when mouse move?

I'm able to make a svg file using gnuplot. when I click any place in the plot, the (x,y) coordinates will show up, when the mouse move, the coordinates change, when I click the plot again, the coordinate disappear.
How to not display the coordinates when mouse click and move?
Thanks!
I have tried:
set mouse noruler
set mouse mouseformat 6
set mouse mouseformat ""
set mouse clipboardformat 6
The code is:
set term svg mouse jsdir "http://.../TEST/"
set output "test.svg"
plot 'test.data' using 1:2:3 with labels hypertext point pt 7
I think I initially misunderstood your question (1st answer now deleted). Let me try again.
You are describing the default behaviour of mousing support in gnuplot+svg.
(1) Simple option: If you don't want any of this, do not include the mouse keyword when you select the terminal.
(2) Infinitely customizable option: The javascript mousing behaviour is implemented in a separate file gnuplot_svg.js. Several versions exist, but you could edit or replace any of them to suit your needs. The most recent version is here:
gnuplot_svg.js
(3) Possible compromise: The *.svg file produced by gnuplot contains lines like this:
<g id="gnuplot_canvas" onclick="gnuplot_svg.toggleCoordBox(evt)" onmousemove="gnuplot_svg.moveCoordBox(evt)">
If you want to disable only the response to mouse clicks, or to mouse movement, edit these lines to remove the corresponding onclick or onmousemove directives.

jQuery Flot: Adjust xaxis zoom in/out to calendar

Using jquery.flot.navigate.js I can have flot zoom in/out on mouse wheel/ double click by specified amount (e.g. x1.5). What I need, is zoom by calender. By that I mean zooming in/out by the boundaries of hour/day/week/month/year.
Is there any way to achieve a callback/ interaction with the navigate plugin or custom solution?
Solved by modifying jquery.flot.navigate.js to call a callback function after adjusting axis min/max due to scale/pan/double-click. The callback can then further adjust the zoom boundaries as needed before the chart is redrawn.

How to drag a polygon in MFC?

I'm new to MFC. I know how to draw a line and how to scribble in MFC. I use CDC and some functions such as LineTo() and MoveTo() to do this. Moreover, I've got FillRect() and Rectangle().Now I want to drag my rectangle or any polygon in the view.It's like you drag a icon on your desktop.
I think the first step is to get the region.Then erase the old polygon and when the mouse move draw a same polygon which depends on the point where the mouse go.
So I search region in MSDN and I got Region class and CRgn class.But before I look into these two class I want to know whether I'm in the right direction.
I need more suggestions on how to learn MFC. Actually,all I need is to finish my homework which is mainly about draw polygons and drag them and link them by line. And I hope I can finish this homework all by myself and MSDN. Can MSDN help me do that?
The CDC::Polyline function will draw a polygon much faster than using LineTo and MoveTo.
You do not need region and do not need to erase the old polygon. Instead, you need to draw everything in the view OnDraw. Any change you want to make with the mouse should change the array of coordinates that represent the polygon and then call Invalidate. In other words, do not draw in the mouse message handlers. Calling Invalidate in the mouse message handlers will cause OnDraw to be called later and it should repaint the entire view.

Resources