how to space overlapping labels in plot

Dear all,
I´m analyzing MRI data and need to plot the intensity values and behavioural scores of a single voxel from a sample of patients. To label the data points, I used the identifier for each patient.
However, even if I decrease the font size for the labels, they overlap for those data points in close spatial proximity. I have tried to get around this by modifying the plot box and data aspect ratio but haven´t solved the problem yet.
I´d really appreciate if someone in the forum could help me with this since I´m sure it will be a recurrent issue in the future.
Here´s the main code I used for the plot. You can find the plot attached.
x=Syl_FJ12_PERC_MODEL_TP1.beh_cov;
y=cell2mat(pa_int_fixed(:,2));
label=pa_int_fixed(:,1);
figure
plot(x,y, '.r','MarkerSize', 15)
text(x, y, label,'fontSize',8);
title ('VBM Sanity check'), ylabel('GM Intensity Peak Voxel (-36 15 -33) Temp_Pole_Mid_L'), xlabel ('Syl JK12 Perc Model')
Thanks in advance for your time,
NoeliaVBM_JK_Syl12_Perc_Model_sanity_check_labels.jpg

댓글 수: 5

dpb
dpb 2019년 12월 6일
Use the picture icon to attach the .jpg, not paperclip so can see it...
Noelia Martínez
Noelia Martínez 2019년 12월 6일
done :)
dpb
dpb 2019년 12월 6일
I don't know how you would expect to not have such occur when data points are so close.
It would take quite a lot of logic to automagically find points within the distance and rearrange their position/orientation parameters to not occlude their neighbors.
What you might consider would be to find those that are close to each other and then somewhere that there's a lot of blank space (seems to be a lot of that available if example is representative) in the general neighborhood use an annotation box to list the points and associate them with just a number index.
Or, alternatively, you could try to use the annotation arrow and randomize or aribtrarily adjust the location relative to the point and label it for those...
Dont believe this is an easy one to solve programmatically...
dpb
dpb 2019년 12월 6일
If you want somebody to perhaps take a shot at it, attach a dataset that reproduces the problem.
Noelia Martínez
Noelia Martínez 2019년 12월 9일
many thanks for taking the time to reply. I thought that a way to solve this would be to programmatically modify the scaling of the axes so that these close data points would be more distant, as it happens when you zoom in on the area where they are located. But, as you pointed out, to do this programmatically is not trivial...
I´ll try to modify the location of the label for these data points either with text or annotation to make sure that they are legible.
best,
Noelia

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

답변 (0개)

카테고리

도움말 센터File Exchange에서 Axis Labels에 대해 자세히 알아보기

태그

질문:

2019년 12월 6일

댓글:

2019년 12월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by