What is the syntax for subscripts in a plot text box?

조회 수: 9 (최근 30일)
Laura
Laura 2013년 7월 9일
I am working on a code to plot a function with a title and an annotation below the graph. So far everything is working smoothly -except- the subscript syntax [ '_' ] is only working in the title and not my annotation text box. i.e. EIF_2 is subscripted, but E_0, k_1, and k_{-1} is not. I'm at a loss. Any suggestions?
A few notes on my code: The annotation text box contains 3 lines of text and "prints" parameter values defined elsewhere in my .m file.
------------------------------------------------------------------------------
Here's the plotting portion of my code:
%Plot the solution
fig1=figure; %Create a new figure
h_axes = axes('parent',fig1,'position',[.1 .3 .8 .6]);
plot(h_axes,t,x(:,1),'r',t,x(:,2),'b',t,x(:,3),'g',t,x(:,4),'m',t,x(:,5),'--r',t,x(:,6),'--b',t,x(:,7),'--g',t,x(:,8),'--m',t,x(:,10),'k', t,x(:,11),'--k')
title(['EIF_2 Subfunction Model 4 -- (Initial PKR = ',num2str(x11),')'])
h_text=uicontrol('style','text','parent',fig1,'units','normalized','position',[.1 .05 .8 .1]);
set(h_text,'string',{[
'Initial Conditions: E_0 = ' ,num2str(E0),';'];
['Forward Parameters: k_1 = ',num2str(k1), ';'];
['Reverse Parameters: k_{-1} = ',num2str(k_1),';'];
})
xlabel('time')
ylabel('State Variable Values')
leg=legend('E_T', 'E_D', 'E_P', 'E_B','C_1','C_2','C_3','C_4','M','Pk','Location','NorthEastOutside');
-------------------------------------------------------------------------------
Any suggestions would be greatly appreciated!
-- Laura

채택된 답변

Dan Seal
Dan Seal 2013년 7월 9일
UICONTROL objects do not support LaTeX or TeX markup. If you search "uicontrol tex" or "uicontrol latex" on Google, you will see links to several possible workarounds that people have found. These sometimes involve other functions that have been posted to the file exchange or other hacks with different types of graphics objects.
The easiest way to get TeX markup in your figure is just to use the TEXT command instead of the UICONTROL command. Be aware that a text object is the child of the axes, so it should be positioned based on the axes units.
  댓글 수: 5
Laura
Laura 2013년 7월 9일
Okay - I'll look into that. Thanks again!
Laura
Laura 2013년 7월 9일
With some minor tweaking to my code it worked like a charm!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by