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

7 ビュー (過去 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 Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by