How to determine Coordinates in a plot

Hello everyone,
I have the following simplified code, creating a subplot in one larger main plot. I want to draw a line between points (A) and (B) by
plot([1.5,1.9],[1.5,2],'LineStyle','--')
I don't know how to determine the coordinates [1.5,1.9],[1.5,2] automatically.
Thanks for any help!
figure
hold on;
plot(magic(2));
plot([1.5,1.9],[1.5,2],'LineStyle','--')
axes('Position',[.2 .2 .3 .3])
plot(magic(2));
text(2,0.2,'\leftarrow from this corner (A)');
text(3,2,'\leftarrow to this point (B)');
hold off

6 件のコメント

Ghazwan
Ghazwan 2017 年 5 月 11 日
編集済み: Ghazwan 2017 年 5 月 11 日
what do you mean by automatically?
KSSV
KSSV 2017 年 5 月 11 日
Can you tell what are points? ([1.5,1.9],[1.5,2]..
Stephan
Stephan 2017 年 5 月 11 日
I'm sorry for this unclear question. To be more specific, I want the coordinates of the edges of the black square
figure
plot(1,1)
axes('Position',[.2 .2 .3 .3])
box('on')
set(gca,'xtick',[]); set(gca,'ytick',[]);
Jan
Jan 2017 年 5 月 11 日
@Stephan: I still do not understand, what you are looking for. Which coordinates? Relative to the monitor, to the figure or to the axes' data? In pixels, normalized or data units? Do you want to take a screenshot and look for black pixels or do you want to set a label directly on top of the lines?
Stephan
Stephan 2017 年 5 月 12 日
Consider the corner at about x=0.2, y=0.2. This corner is not exactly in x=0.2, y=0.2. I want to know the exact x- and y-coordinate of this point.
Gaurav Ahuja
Gaurav Ahuja 2017 年 5 月 16 日
the Coordinates in a plot of the points plotted are saved in the corresponding object's (say line object) Xdata and YData (or Zdata).
if you are looking at the edges of axes, that information can be extracted from the 'position' field of the axes and 'Units' are generally normalized.
take a look at the following link to understand how to get these values, and you can tweak some code for your use case.
I agree with @Jan Simon, you do need to identify those requirements and ask a specific question again.
And how do you wish to get these coordinates, graphically or in a script?

回答 (0 件)

この質問は閉じられています。

質問済み:

2017 年 5 月 10 日

閉鎖済み:

2017 年 5 月 23 日

Community Treasure Hunt

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

Start Hunting!

Translated by