Python Forum
[Tkinter] cursor cross hairs want date not x index
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] cursor cross hairs want date not x index
#1
I am using the following cursor class called from a data manipulation routine. I simply want to output the date from the xaxis not the x value (0-24) that represents the total count values avaiable on the x axis of the mouse as it is moved in (x).

Currently it outputs correctly (x,y) values as it was intended by whoever wrote this (matplotlib).
I simply want (xdate, y). Where x date is the real xaxis value

I wanted to post a photo but I dont have an url ... its on the local machine?
Basically the values displayed as the mouse moves look like (14.39, 5.32)




import matplotlib.pyplot as plt
import numpy as np
import pandas as pd

class Cursor(object):
    def __init__(self, ax):
        self.ax = ax
        self.lx = ax.axhline(color='k')  # the horiz line
        self.ly = ax.axvline(color='k')  # the vert line

        # text location in axes coords
        self.txt = ax.text(0.7, 0.9, '', transform=ax.transAxes)

    def mouse_move(self, event):
        if not event.inaxes:
            return

        x, y = event.xdata, event.ydata
        # update the line positions
        self.lx.set_ydata(y)
        self.ly.set_xdata(x)

        self.txt.set_text('x=%1.2f, y=%1.2f' % (x, y))
        self.ax.figure.canvas.draw()
Any help would be really appreciated
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] Take the variable of a cursor class delcencen 2 1,189 Feb-13-2023, 05:19 AM
Last Post: deanhystad
  [Tkinter] Finding out what's under the cursor sabresong 3 2,712 Mar-28-2020, 02:52 PM
Last Post: sabresong
  [Tkinter] Modifications on cursor Zyxcel314 3 2,999 Jun-04-2018, 04:36 PM
Last Post: Larz60+
  [Tkinter] Problem of cursor force_tranquille 0 2,130 May-07-2018, 09:20 AM
Last Post: force_tranquille
  [Tkinter] Scroll at cursor position lollo 4 6,254 Jan-31-2018, 11:33 PM
Last Post: lollo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020