<h3 dir="auto">Bug report</h3>
<p dir="auto">The coordinates reported for <code class="notranslate">eclick</code> and <code class="notranslate">erelease</code> from the <code class="notranslate">onselect</code> callback function don't match what was actually clicked on when drawing a rectangle with <code class="notranslate">RectangleSelector</code></p>
<p dir="auto"><strong>Code for reproduction</strong></p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="from matplotlib.backend_bases import MouseButton, MouseEvent
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.widgets import RectangleSelector


xdata = np.linspace(0,9*np.pi, num=301)
ydata = np.sin(xdata)

def rect_coords_from_clicks(eclick, erelease):
    x1, y1 = eclick.xdata, eclick.ydata
    x2, y2 = erelease.xdata, erelease.ydata
    print(f&quot;You pressed at {(x1,y1)}, and released at {(x2,y2)}.&quot;)

def on_press(event):
    print(f&quot;You pressed {str(event.button)} at {(event.xdata, event.ydata)}.&quot;)

def on_release(event):
    print(f&quot;You released {str(event.button)} at {(event.xdata, event.ydata)}.&quot;)

fig, ax = plt.subplots()
line, = ax.plot(xdata, ydata)

rs = RectangleSelector(ax, rect_coords_from_clicks, button=[MouseButton.LEFT])

plt.connect('button_press_event', on_press)
plt.connect('button_release_event', on_release)

plt.show()"><pre class="notranslate"><span class="pl-k">from</span> <span class="pl-s1">matplotlib</span>.<span class="pl-s1">backend_bases</span> <span class="pl-k">import</span> <span class="pl-v">MouseButton</span>, <span class="pl-v">MouseEvent</span>
<span class="pl-k">import</span> <span class="pl-s1">matplotlib</span>.<span class="pl-s1">pyplot</span> <span class="pl-k">as</span> <span class="pl-s1">plt</span>
<span class="pl-k">import</span> <span class="pl-s1">numpy</span> <span class="pl-k">as</span> <span class="pl-s1">np</span>
<span class="pl-k">from</span> <span class="pl-s1">matplotlib</span>.<span class="pl-s1">widgets</span> <span class="pl-k">import</span> <span class="pl-v">RectangleSelector</span>


<span class="pl-s1">xdata</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">linspace</span>(<span class="pl-c1">0</span>,<span class="pl-c1">9</span><span class="pl-c1">*</span><span class="pl-s1">np</span>.<span class="pl-s1">pi</span>, <span class="pl-s1">num</span><span class="pl-c1">=</span><span class="pl-c1">301</span>)
<span class="pl-s1">ydata</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">sin</span>(<span class="pl-s1">xdata</span>)

<span class="pl-k">def</span> <span class="pl-en">rect_coords_from_clicks</span>(<span class="pl-s1">eclick</span>, <span class="pl-s1">erelease</span>):
    <span class="pl-s1">x1</span>, <span class="pl-s1">y1</span> <span class="pl-c1">=</span> <span class="pl-s1">eclick</span>.<span class="pl-s1">xdata</span>, <span class="pl-s1">eclick</span>.<span class="pl-s1">ydata</span>
    <span class="pl-s1">x2</span>, <span class="pl-s1">y2</span> <span class="pl-c1">=</span> <span class="pl-s1">erelease</span>.<span class="pl-s1">xdata</span>, <span class="pl-s1">erelease</span>.<span class="pl-s1">ydata</span>
    <span class="pl-en">print</span>(<span class="pl-s">f"You pressed at <span class="pl-s1"><span class="pl-kos">{</span>(<span class="pl-s1">x1</span>,<span class="pl-s1">y1</span>)<span class="pl-kos">}</span></span>, and released at <span class="pl-s1"><span class="pl-kos">{</span>(<span class="pl-s1">x2</span>,<span class="pl-s1">y2</span>)<span class="pl-kos">}</span></span>."</span>)

<span class="pl-k">def</span> <span class="pl-en">on_press</span>(<span class="pl-s1">event</span>):
    <span class="pl-en">print</span>(<span class="pl-s">f"You pressed <span class="pl-s1"><span class="pl-kos">{</span><span class="pl-en">str</span>(<span class="pl-s1">event</span>.<span class="pl-s1">button</span>)<span class="pl-kos">}</span></span> at <span class="pl-s1"><span class="pl-kos">{</span>(<span class="pl-s1">event</span>.<span class="pl-s1">xdata</span>, <span class="pl-s1">event</span>.<span class="pl-s1">ydata</span>)<span class="pl-kos">}</span></span>."</span>)

<span class="pl-k">def</span> <span class="pl-en">on_release</span>(<span class="pl-s1">event</span>):
    <span class="pl-en">print</span>(<span class="pl-s">f"You released <span class="pl-s1"><span class="pl-kos">{</span><span class="pl-en">str</span>(<span class="pl-s1">event</span>.<span class="pl-s1">button</span>)<span class="pl-kos">}</span></span> at <span class="pl-s1"><span class="pl-kos">{</span>(<span class="pl-s1">event</span>.<span class="pl-s1">xdata</span>, <span class="pl-s1">event</span>.<span class="pl-s1">ydata</span>)<span class="pl-kos">}</span></span>."</span>)

<span class="pl-s1">fig</span>, <span class="pl-s1">ax</span> <span class="pl-c1">=</span> <span class="pl-s1">plt</span>.<span class="pl-en">subplots</span>()
<span class="pl-s1">line</span>, <span class="pl-c1">=</span> <span class="pl-s1">ax</span>.<span class="pl-en">plot</span>(<span class="pl-s1">xdata</span>, <span class="pl-s1">ydata</span>)

<span class="pl-s1">rs</span> <span class="pl-c1">=</span> <span class="pl-v">RectangleSelector</span>(<span class="pl-s1">ax</span>, <span class="pl-s1">rect_coords_from_clicks</span>, <span class="pl-s1">button</span><span class="pl-c1">=</span>[<span class="pl-v">MouseButton</span>.<span class="pl-v">LEFT</span>])

<span class="pl-s1">plt</span>.<span class="pl-en">connect</span>(<span class="pl-s">'button_press_event'</span>, <span class="pl-s1">on_press</span>)
<span class="pl-s1">plt</span>.<span class="pl-en">connect</span>(<span class="pl-s">'button_release_event'</span>, <span class="pl-s1">on_release</span>)

<span class="pl-s1">plt</span>.<span class="pl-en">show</span>()</pre></div>
<p dir="auto"><strong>Actual outcome</strong></p>
<p dir="auto">clicking the left mousebutton at ~(0,0), dragging the rectangle to ~(25,-1) and then releasing results in the following</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="You pressed MouseButton.LEFT at (0.028502352703939415, -0.009523809523809268).
You pressed at (0.028502352703938527, -0.9976190476190476), and released at (24.922457204324836, -0.009523809523809268).
You released MouseButton.LEFT at (24.922457204324836, -0.9976190476190476)."><pre class="notranslate"><code class="notranslate">You pressed MouseButton.LEFT at (0.028502352703939415, -0.009523809523809268).
You pressed at (0.028502352703938527, -0.9976190476190476), and released at (24.922457204324836, -0.009523809523809268).
You released MouseButton.LEFT at (24.922457204324836, -0.9976190476190476).
</code></pre></div>
<p dir="auto">clicking the left mousebutton at ~(25,1), dragging the rectangle to ~(0,0) and then releasing results in the following</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="You pressed MouseButton.LEFT at (25.04786755622217, -0.9797619047619047).
You pressed at (0.028502352703938527, -0.9797619047619047), and released at (25.04786755622217, 0.0023809523809525945).
You released MouseButton.LEFT at (0.028502352703939415, 0.0023809523809525945)."><pre class="notranslate"><code class="notranslate">You pressed MouseButton.LEFT at (25.04786755622217, -0.9797619047619047).
You pressed at (0.028502352703938527, -0.9797619047619047), and released at (25.04786755622217, 0.0023809523809525945).
You released MouseButton.LEFT at (0.028502352703939415, 0.0023809523809525945).
</code></pre></div>
<p dir="auto">The coordinates of click and release aren't respected by the onselect function of RectangleSelector: the "click" coordinate is always the bottom left corner of the rectangle and the "release" coordinate is always the top right corner.</p>
<p dir="auto">The coordinates given by the <code class="notranslate">on_press</code> and <code class="notranslate">on_release</code> functions are always correct.</p>
<p dir="auto"><strong>Expected outcome</strong></p>
<p dir="auto">clicking the left mousebutton at ~(0,0), dragging the rectangle to ~(25,-1) and then releasing results in the following</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="You pressed MouseButton.LEFT at (0.028502352703939415, -0.009523809523809268).
You pressed at (0.028502352703939415, -0.009523809523809268), and released at (24.922457204324836, -0.9976190476190476).
You released MouseButton.LEFT at (24.922457204324836, -0.9976190476190476)."><pre class="notranslate"><code class="notranslate">You pressed MouseButton.LEFT at (0.028502352703939415, -0.009523809523809268).
You pressed at (0.028502352703939415, -0.009523809523809268), and released at (24.922457204324836, -0.9976190476190476).
You released MouseButton.LEFT at (24.922457204324836, -0.9976190476190476).
</code></pre></div>
<p dir="auto">clicking the left mousebutton at ~(25,1), dragging the rectangle to ~(0,0) and then releasing results in the following</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="You pressed MouseButton.LEFT at (25.04786755622217, -0.9797619047619047).
You pressed at (25.04786755622217, -0.9797619047619047), and released at (0.028502352703939415, 0.0023809523809525945).
You released MouseButton.LEFT at (0.028502352703939415, 0.0023809523809525945)."><pre class="notranslate"><code class="notranslate">You pressed MouseButton.LEFT at (25.04786755622217, -0.9797619047619047).
You pressed at (25.04786755622217, -0.9797619047619047), and released at (0.028502352703939415, 0.0023809523809525945).
You released MouseButton.LEFT at (0.028502352703939415, 0.0023809523809525945).
</code></pre></div>
<p dir="auto">The coordinates reported by <code class="notranslate">eclick</code> and <code class="notranslate">erelease</code> should match the actual click and release coordinate.</p>
<p dir="auto"><strong>Matplotlib version</strong></p>
<ul dir="auto">
<li>Operating system: Windows 10</li>
<li>Matplotlib version: 3.4.2</li>
<li>Matplotlib backend: Qt5Agg</li>
<li>Python version: 3.9.4</li>
</ul>
<h3 dir="auto">Bug report</h3>
<p dir="auto">In Python 3.6.3 and the related matplotlib (just compiled from sources) the RectangleSelector does no longer behave as in Python 2.7 and as is described. Instead of returning the mouse click coordinates in the event variable eclick and the release coordinates in erelease it returns the lower left corner in eclick and the upper right corner in erelease. This "normalization" reduces the information content and, thus, the usability of the selector. Only using the old version a user can switch to drawmode='line' and use the selector to input a displacement vector.</p>