There is a ready to use matplotlib toolbar button to measure axis delta in selected range?

Viewed 158

I have simple app of matplotlib figure with toolbar, code:

import tkinter as tk
import numpy as np

from matplotlib import pyplot
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2Tk

root = tk.Tk()

fig, ax = pyplot.subplots()
arr = np.arange(0, 3, .01)
ax.plot(arr, 2 * np.sin(2 * np.pi * arr))

canvas = FigureCanvasTkAgg(fig, master=root)
canvas.draw()

NavigationToolbar2Tk(canvas, root)

canvas.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=1)

tk.mainloop()

Result: Code Result

I want to add an interactive "Range Measure" tool button to show X values delta in the selected range.

After choosing the tool from the toolbar, the user clicks on the figure, and dragging the mouse left or right, and the closing range line moving respectively until release the mouse button.

Desired example (created with paint): Desired Feature

I know I can implement it using canvas events binds, but before doing it, I want to know if there is such a thing ready to use? Thanks!

0 Answers
Related