What is the syntax for subscripts in a plot text box?
7 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!