gpt4 book ai didi

matlab - 使用plotyy 打破Matlab 图例中的长文本

转载 作者:行者123 更新时间:2023-12-02 21:33:23 25 4
gpt4 key购买 nike

我的情节中的图例太长,如何将其分成两行?我正在使用 plotyy 进行绘图并使用以下代码:

leg = sprintf('I_{fitting}=I_0/(\surd{2\pi}\sigma)e^{-[t-t_0]^2/(2.\sigma^2)};\nso t_0=0.2\mus;\sigma=0.09\mus;I_0=4.8\cdot10^{10}W/cm^2') 
legend([h1 h2], 'I=10^{14}[T_e/(3680(1.054)^{1/3})]^{1.5}',leg);

你能告诉我问题是什么吗?

最佳答案

试试这个

>> leg = sprintf('This is a really long line\nso I broke it in two')
>> plot(1:10, 1:10)
>> legend(leg)

结果

enter image description here

如果图例中有其他字符需要转义(例如,如果有大量 LaTeX),则此方法将不起作用。在这种情况下,您可以手动插入换行符 -

>> newline = char(10);
>> leg = ['This is the first line', newline, 'and the second: A = 2\pi r^2'];
>> plot(1:10, 1:10);
>> legend(leg)

结果

enter image description here

关于matlab - 使用plotyy 打破Matlab 图例中的长文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21887806/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com