이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
Text overlapp in uifigure plot
조회 수: 40 (최근 30일)
이전 댓글 표시
Hi
I'm using text to plot the text in a user interface figure (x,y,str). I was unable to see the original text message since they overlapped.
Can someone please tell me how to prevent the words from overlapping?
Thank you!
댓글 수: 19
Adam Danz
2020년 6월 10일
Could you show us how you're plotting the text? It would be helpful if you could isolate the section of code that plots the text and explain it rather than sharing a bunch of code that isn't related to the text.
Life is Wonderful
2020년 6월 10일
Below is the code snippet performing the text plot.
c= app.UITable.Data;
s_DropDown1 = app.UITable.Data.(app.DropDown1.Value);
s_DropDown2 = app.UITable.Data.(app.DropDown2.Value);
range = (x);
h = duration([c{range,1}]);
hold(app.UIAxes,'on'); grid(app.UIAxes,'minor');
plot(app.UIAxes,h,range,"Color",rand(1,3));
set(0,'DefaultTextInterpreter','none');
hText1 = text(app.UIAxes,h,range,s_DropDown1(range),range,'VerticalAlignment','bottom',"FontSize",12, "Color",rand(1,3));
hText2 = text(app.UIAxes,h,range,s_DropDown2(range),range,'VerticalAlignment','bottom',"FontSize",12.5, "Color",rand(1,3));
Adam Danz
2020년 6월 10일
It looks like you're plotting the text in the same position in two different lines. Of course it will overlap.
Are you familiar with the text() inputs? If not, check out the documentation.
Life is Wonderful
2020년 6월 11일
편집: Life is Wonderful
2020년 6월 11일
Thanks Adam,
I am NOT clear, what is the meaning of position of Text. It can be
Case -1
||Time || Message
|00.00.00.001 | str1 str2 % Line 1 with Dropdown1 cell data & Dropdown2 CellData
Case -2
||Time || Message
|00.00.00.001 | str1 % Line 1
|00.00.00.001 | str2 % Line 2
How do i postion string in a designated postion ?
I want text print to be like Case -1/ since my text data is from same line and NOT next line but they are overlapped , I want the text overlap data (from each Dropdown menu) to be removed
Probably i can think of below example . Case 2 works better than other cases!
Can you please help me with better explanation for my implementation needs?
Thank you!
clc;close all;
x = [1:5] ;
y = [1:5] ;
bit_position = 2;
str1 = ['one '];
str2 = ['two '];
str3 = ['three'];
str4 = ['four '];
str5 = ['five '];
str = ['One',...
'Two',...
'Three',...
'Four',...
'Five'];
for i = 1:numel(x)
plot(x,y);
if isequal(bit_position,1)
subplot(3,1,1);
text(x(i),y(i),str(i), 'position',[i/numel(x) i/numel(x)]);
xlabel('xTicks');ylabel('MSG');
elseif isequal(bit_position,2)
subplot(3,1,2);
text(x(1),y(1),str1,'position',[1 10]);
text(x(2),y(2),str2,'position',[1 10]);
text(x(3),y(3),str3,'position',[1 10]);
text(x(4),y(4),str4,'position',[1 10]);
text(x(5),y(5),str5,'position',[1 10]);
xlabel('xTicks');ylabel('MSG');
elseif isequal(bit_position,3)
subplot(3,1,3);
text(x(1:numel(x)),y(1:numel(x)),str(1:numel(x)),'position',[i/numel(x) i/numel(x)]);
% text(x(1:numel(x)),y(1:numel(x)),str(1:numel(x)),'position',[1 10]);
xlabel('xTicks');ylabel('MSG');
end
end
Adam Danz
2020년 6월 11일
Check out how the text function works. The first two inputs set the location of the text.
In your examples, you need to add hold on within each of the if/else-if blocks.
Going back to the original questions, I'm really lost about,
- What the final result should look like
- What the text inputs look like;
- How you want to position the text
It would be clearer if you could somehow illustrate what the final result should look like and what your inputs look like.
Life is Wonderful
2020년 6월 11일
편집: Life is Wonderful
2020년 6월 12일
Problem statement : In 2nd figure, 1st & 2nd Text data is overlapping
: In 3nd figure, 1st , 2nd and 3rd Text data is overlapping
Requirement: From the below table , plot the text data in a Non-overlapp.
1×4 table
WeirdDuration log_autoserv1_autoserv Sublog_autoserv1_autoserv Message_autoserv1_autoserv
_____________ ______________________ _________________________ ______________________________________________________________________________________________________
00:00:00.000 {'INFO |'} {'pidfile:0016|'} {'Logged pid 4404 to /tmp/test_that_results_hatch_QIZGx2/results-07-firmware_Mosys/.autoserv_execute'}
Adam Danz
2020년 6월 11일
I'm still very lost.
I don't have a mental image of what text you want to plot and where the text should go in the figure.
I dont' understand why you're plotting text at certain locations in the plot.
I don't understand what parts of the text should be included on the plot.
I don't understand what determines the (x,y) coordinates of the text.
If you can reduce the problem to a very small example (just a few lines of code) that demonstrates the inputs and the expected outputs for a few samples of text (2-3) it might be helpful.
Spend some time reading about the text() function in the documentation and going through the examples. That might be a much faster path toward a solution than trying to explain the problem a few times and waiting for a response.
Life is Wonderful
2020년 6월 12일
편집: Life is Wonderful
2020년 6월 12일
I don't have a mental image of what text you want to plot and where the text should go in the figure.
- I want to plot text data against time of occurance/Time vs message. I have text data point on same time.
I dont' understand why you're plotting text at certain locations in the plot.
- I am not plotting text to a location. The text('position',[]) - is not used. This is an issue for now.
I don't understand what parts of the text should be included on the plot.
- I want to plot , Time vs Message.
I don't understand what determines the (x,y) coordinates of the text.
- x-axsis = time[WeirdDuration]/row,
- y-axis = message[log_autoserv1_autoserv,Sublog_autoserv1_autoserv,Message_autoserv1_autoserv]/column
WeirdDuration log_autoserv1_autoserv Sublog_autoserv1_autoserv Message_autoserv1_autoserv
_____________ ______________________ _________________________ ______________________________________________________________________________________________________
00:00:00.000 {'INFO |'} {'pidfile:0016|'} {'Logged pid 4404 to /tmp/test_that_results_hatch_QIZGx2/results-07-firmware_Mosys/.autoserv_execute'}
plot(x,y,str) ==> plot(x,y,str,'position',[ ]) , Note 'position',[ ] is missing
hTxt1 = text(app.axis,WeirdDuration,log_autoserv1_autoserv) ==> text(00:00:00.000,{'INFO |'})
hTxt2 = text(app.axis,WeirdDuration,Sublog_autoserv1_autoserv) ==> text(00:00:00.000,{'pidfile:0016|'})
hTxt3 = text(app.axis,WeirdDuration, Message_autoserv1_autoserv) ==> text(00:00:00.000,{'Logged pid 4404 to /tmp/test_that_results_hatch_QIZGx2/results-07-firmware_Mosys/.autoserv_execute'})
OK, I will take time to understand text() function and file exchange,
Thank you!
Life is Wonderful
2020년 6월 12일
편집: Life is Wonderful
2020년 6월 12일
The problem statement and concept was in place.
Instead of subplots- I was adding the one figure.The attached code[appdesigner("SysDebug_AppDesign")] is where Text overlap is there. So I need your help
Adam Danz
2020년 6월 12일
1) I'm not sure what I'm supposed to do with the app.
2) "The text('position',[]) - is not used. This is an issue for now." -- I don't understand this. text() is a function and the (x,y) position inputs are required. So I don't know what it means that the text position is not used.
3) "I want to plot , Time vs Message." I understand that time is along the x axis but what are the units of "message" along the y axis?
4) "I will take time to understand text() function " I think it may take an hour or two. But keep in mind this discussion has continued for ~2 days so reading through the documentation and truely understanding the inputs to the text() function will be faster.
I'd really like to help but the problem is still unclear.
Check out this example below and tell me if it's helpful or related to what you want to do.
fig = figure();
ax = axes(fig);
textSamples = {'First Row', 'Second Row', 'Third Row'};
x = 1:3
y = 1:3;
plot(ax, x, y, 'bo')
hold(ax, 'on')
% Example of text()
text(ax, x+.05, y, textSamples,'HorizontalAlignment', 'Left')
xlim([0,4])
ylim([0,4])
% example of labelpoints()
labelpoints(x,y,textSamples,'N','color','b') % N is for North
Life is Wonderful
2020년 6월 12일
편집: Life is Wonderful
2020년 6월 12일
Hi Adam,
I understood the issue more from your figure. Thank you very much!
Let's say
- x-+.25 means we are shifting the text location by 0.25 units on time scale(x -co ordinate).
- y-+.25 means we are shifting the text location by 0.25 units on Index scale(y -co ordinate)
That means co ordinates will changes.
In case , if we use marker to indicate location and shift the text, then the problem straring " how long one can define text position shift space" ? There can be possibility of additional Text in waiting to surface on the figure
In -fact , I was asking on the same axis (x,y) points I had the multiple text data.
I don't know - how to define the concept....
K>> text(app.UIAxes,h,range,s_DropDown1(range),range,'VerticalAlignment','bottom',"FontSize",12, "Color",rand(1,3));
K>> text(app.UIAxes,h+0.25,range,s_DropDown1(range),range,'VerticalAlignment','bottom',"FontSize",12, "Color",rand(1,3))
K>> text(app.UIAxes,h,range+0.25,s_DropDown1(range),range,'VerticalAlignment','bottom',"FontSize",12, "Color",rand(1,3))
K>> text(app.UIAxes,h,range-0.25,s_DropDown1(range),range,'VerticalAlignment','bottom',"FontSize",12, "Color",rand(1,3))
K>> text(app.UIAxes,h-0.25,range,s_DropDown1(range),range,'VerticalAlignment','bottom',"FontSize",12, "Color",rand(1,3))
Adam Danz
2020년 6월 12일
Are you talking about the Horizontal and Vertical Alignment properties?
figure()
axes()
xlim([-1 1])
ylim([-1 1])
hold on
plot(0,0,'rx')
text(0, 0, 'A', 'HorizontalAlignment', 'Left', 'VerticalAlignment', 'Middle')
text(0, 0, 'B', 'HorizontalAlignment', 'Right', 'VerticalAlignment', 'Middle')
text(0, 0, 'C', 'HorizontalAlignment', 'Center', 'VerticalAlignment', 'Top')
text(0, 0, 'D', 'HorizontalAlignment', 'Center', 'VerticalAlignment', 'Bottom')
Adam Danz
2020년 6월 12일
Ah... good.
Note that you can also do the same thing with
labelpoints(0, 0, 'A', 'E') % For east
labelpoints(0, 0, 'B', 'W') % for west
labelpoints(0, 0, 'C', 'S') % For south
labelpoints(0, 0, 'D', 'N') % For north
% Also NE NW SE SW and C for center
In addition, you can offset the label from the coordinate by using
labelpoints(0, 0, 'D', 'N', 0.1) % where 0.1 is an offset factor
Adam Danz
2020년 6월 12일
That's because this discussion has been in the comments section. I just added an answer that summarizes the solution.
채택된 답변
Adam Danz
2020년 6월 12일
Here are two ways to control the position of text in a plot
Use Matlab's text() function
The HorizontalAlignment and VerticalAlignment properties control the text position relative to the coordinate.
fig = figure();
ax = axes(fig);
textSamples = {'First Row', 'Second Row', 'Third Row'};
x = 1:3
y = 1:3;
plot(ax, x, y, 'bo')
hold(ax, 'on')
% Example of text()
text(ax, x+.05, y, textSamples,'HorizontalAlignment', 'Center', 'VerticalAlignment', 'Bottom')
xlim([0,4])
ylim([0,4])
The same example above can be done with this line below. The 'N' input specifies that the text should be North of the coordinates.
labelpoints(x,y,textSamples,'N','color','b') % N is for North
댓글 수: 2
Life is Wonderful
2020년 7월 19일
Hi Adam,
Can you please help with below link issue
You suggestion and guidance would be a great help for me ! Thank you!
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
태그
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
아시아 태평양
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)