問題圖例框中不居中
我創建使用plotyy如圖片示出在其框不居中的情節的說明:
這是第一次這發生在我身上,而且出口到各種形式的問題後,問題仍然存在。我正在使用Matlab R2016a。
代碼
我用下面的代碼繪製的傳說:
a=sprintf('Test')
b=sprintf('Test.\nTest Test')
c=sprintf('Test\nTest')
d=sprintf('TestTest\nTest')
e=sprintf('Test\nTest')
f=sprintf('Test\nTest Test')
hLegend=legend([l1,l2,r1,r2,r3,r4], a, b, c, d, e, f);
set([gca,hXLabel,hYLabel,hLegend] , 'FontName' , 'Helvetica','FontSize', 8)
set(hLegend,'Fontsize',8,'Location', 'southoutside', 'Orientation','horizontal')
因此這個問題,有沒有人有這個問題了嗎?有沒有辦法解決這個問題,或者我可以手動將圖例居中?
可執行的代碼示例
h=figure
x=[1:10]
y=[1:10]
hold on
yyaxis left
l1=plot(x,y)
l2=plot(x,2*y)
hYLabel=ylabel('Test')
yyaxis right
r1=plot(x,y.^2)
r2=plot(x,y.^3)
r3=plot(x,10*y)
r4=plot(x,20*y)
hYLabel=ylabel('Test2')
hXLabel = xlabel('TestTest]');
a=sprintf('Test')
b=sprintf('Test.\nTest Test')
c=sprintf('Test\nTest')
d=sprintf('Test\nTest')
e=sprintf('Test\nTest')
f=sprintf('TestTest\nTest')
hLegend=legend([l1,l2,r1,r2,r3,r4], a, b, c, d, e, f);
set([gca,hXLabel,hYLabel,hLegend] , 'FontName' , 'Helvetica','FontSize', 8)
set(hLegend,'Fontsize',8,'Location', 'southoutside', 'Orientation','horizontal')
set(gca,'LineWidth',1.0)
set(l1, 'LineWidth',1.5,'LineStyle','-')
set(l2, 'LineWidth',1.5,'LineStyle','-.')
set(r1, 'LineWidth',1.5,'LineStyle','-')
set(r2, 'LineWidth',1.5,'LineStyle','-.')
set(r3, 'LineWidth',1.5)
set(r4, 'LineWidth',1.5,'LineStyle','- -')
hold off
雖然沒有顯示使用的原始數據,我用上面的例子中得到了同樣的問題。 非常感謝!
我得到一個錯誤信息:*未定義的函數或變量「L1」 *你可以請張貼一個可執行的代碼示例? – Rotem
@Rotem我加了一個可執行版本的代碼 – KiW