MATLAB Answers

GUI - Text to label scatter plot data gets ignored / only works when running function multiple times

2 views (last 30 days)
nickname123
nickname123 on 30 Jun 2015
Answered: Sid on 30 Jun 2015
Hi all,
The following function in a GUI (linked to a push button) displays a scatter plot, which works fine However, the TEXT function to label the data points does not work (without an error message being shown), no data labels are being displayed. It sometimes works after running the function multiple times but also without clear pattern. Any ideas?
Thanks for the help!
%Create Chart
x_axis = data.DUR_ADJ_MID(issuer,:);
y_axis = data.YAS_ZSPREAD(issuer,:);
c_colour = colourcode(issuer,:);
scatter(handles.CHART1,x_axis,y_axis,12,c_colour,'filled');
title(handles.CHART1,'Market Screening');
xlabel(handles.CHART1,'Mod. Duration');
ylabel(handles.CHART1,'Z-Spread');
ylim(handles.CHART1,[ZS_MIN ZS_MAX]);
text(x_axis+0.02,y_axis,data.SECURITY_DES(issuer,:),'FontSize',7,'Color',[1 1 1]);
set (handles.CHART1, 'Color', [0 0 0] );
set (handles.CHART1, 'XColor', [1 1 1] );
set (handles.CHART1, 'YColor', [1 1 1] );

Answers (1)

Sid
Sid on 30 Jun 2015
Should there be a hold on between ylim and text?
Also, one thing I find useful when setting axes is to have a clear axes set up at the beginning of the plot handle I am about to plot in. That way, I am always sure that there are not artifacts from the previous plot left behind.
There is an example from a similar question here.
HTH.

Tags

Community Treasure Hunt

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

Start Hunting!