wx.lib.plot , how to get x, y position of canvas area?

Hi!

I have drawn plotgraph (wx.lib.plot) and I would like to know exact
coordinates (x,y screen coordinates) of the drawn plot canvas area. (I don't
mean the x,y coordinates of the whole plotcanvas including labels/etc. but
only the area where datapoints are drawn)

Is there any way to get those coordinates?

thx

···


View this message in context: http://www.nabble.com/wx.lib.plot-%2C-how-to-get-x%2Cy-position-of-canvas-area--tp19793620p19793620.html
Sent from the wxPython-users mailing list archive at Nabble.com.

solved my problem surprisingly fast :slight_smile:

#to get coordinates or the "grid area":
p1, p2 = gc.boundingBox()
ptx, pty, rectwidth, rectheight = plottercanvas._point2ClientCoord(p1, p2)

#where gc is instance of PlotGraphics and plottercanvas is my instance of
PlotCanvas
#ptx = x coordinate
#pty = y coordinare
#rectwidth = width of rectangle
#rectheight = height of rectangle

···


View this message in context: http://www.nabble.com/wx.lib.plot-%2C-how-to-get-x%2Cy-position-of-canvas-area--tp19793620p19793898.html
Sent from the wxPython-users mailing list archive at Nabble.com.

kewlar wrote:

solved my problem surprisingly fast :slight_smile:

#to get coordinates or the "grid area":
p1, p2 = gc.boundingBox()
ptx, pty, rectwidth, rectheight = plottercanvas._point2ClientCoord(p1, p2)

oh, actually the ptx and pty coordinates are coordinates for "top most and
top left(?)" points :smiley:

but it you use:
      plottercanvas.SetXSpec(type="min")
      plottercanvas.SetYSpec(type="min")
      (where plottercanvas is instance of PlotCanvas)

to resize/fit datapoints into graph, then those coordinates are right :slight_smile:

···

--
View this message in context: http://www.nabble.com/wx.lib.plot-%2C-how-to-get-x%2Cy-position-of-canvas-area--tp19793620p19794066.html
Sent from the wxPython-users mailing list archive at Nabble.com.

ok, I found that there is PositionUserToScreen method ;D
and using GetYCurrentRange() & GetXCurrentRange() I can get proper results
even if I use plotcanvas.SetYSpec(type="auto") :slight_smile:

      y_range = self.plotter_rec.GetYCurrentRange()
      x_range = self.plotter_rec.GetXCurrentRange()
      point1 = (x_range[0],y_range[0])
      point2 = (x_range[1],y_range[1])
      array_1, array_2 = plotcanvas.PositionUserToScreen((point1, point2))

      x1 = array_1[0]
      x2 = array_1[1]
      y1 = array_2[1]
      y2 = array_2[0]
      
      print x1,y1,x2,y2

I don't know why it is needed to "rotate" those x,y coordinates so much...
well, I'm tired now and this solution is good enough

···


View this message in context: http://www.nabble.com/wx.lib.plot-%2C-how-to-get-x%2Cy-position-of-canvas-area--tp19793620p19795199.html
Sent from the wxPython-users mailing list archive at Nabble.com.