Reverse y Coordinate Obtained Using get(handles.axesImage, 'CurrentPoint')

조회 수: 1 (최근 30일)
Hi everyone,
I have code that obtains the [x,y] coordinates of a mouse click from an axes plot (get(handles.axesImage, 'CurrentPoint')). The problem is, the origin for the get coordinates is the top left corner of the axes plot, but I want the origin to be the bottom left corner. I've tried setting the YDir property to reverse, but this doesn't work. Alternatively, how do I get the length of the axes in units of coordinates? I could reverse the y coordinate in brute force fashion if I knew how to do this. Why on earth would the origin be set to the top left to begin with? I understand that it's conducive to plotting matrices, but from a graphical standpoint it's more intuitive thinking that the bottom left is the origin.
Jeff

채택된 답변

Jan
Jan 2011년 9월 9일
It is the other way around in MATLAB: Plotting matrices start in the bottom left corner, while images get the reverse order and start in the top left corner. Therefore you need to set the YDir to 'normal', not to 'reverse'.
You can get the length of the axes by reading the XLim and YLim properties.
  댓글 수: 1
Jeff
Jeff 2011년 9월 10일
Thanks Jan, the XLim and YLim properties did the job.
I tried changing YDir to normal and it doesn't help.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Geometric Geodesy에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by