matlab - Legend entries out of box
问题描述
I am using semilogx
to plot data. Whenever I save the generated graph as an eps or a pdf file, legend entries go out the legend box (see the attachment). However, for .jpg it works fine. Please advise.
Following is the sample code that I use for plot:
[fa,xa] = ecdf(Variable_1);
[fb,xb] = ecdf(Variable_2);
set(0,'DefaultLineLineWidth',3)
set(0,'DefaultAxesFontName','Helvetica')
set(0,'DefaultAxesFontSize',18)
set(0,'DefaultTextFontName','Helvetica')
set(0,'DefaultTextFontSize',18)
semilogx(xa,fa,'b--');
hold all
semilogx(xb,fb,'r--');
hold all
legend({'Availability', 'Unavailability'},'location','northwest');
xlabel('Intervals (hours)');
ylabel('Cumulative fraction');
grid off
解决方案
My first choice would be to get rid of the box:
legend({'Availability','Unavailability'},'location','northwest','box','off')
If you really want the box, you can manually increase its size, e.g. the increase width by 10%:
lposincr = [0 0 .1 0]; % left, bottom, width, height
l = legend({'Availability', 'Unavailability'},'location','northwest');
lpos = get(l,'Position');
set(l,'Position',lpos.*(1+lposincr))
推荐阅读
- c# - 从应用商店下载时,Xamarin.iOS 应用在使用 iPhone5 启动时崩溃。DYLD,库未加载错误。-+
- symfony - Symfony 4 学说即使在开发环境中也使用缓存
- java - 扫描文本文件时出现 NetBeans 错误
- dart - Dart 中的 this[x] 等价于什么?
- .htaccess - Apache 重定向指令不作为最终规则
- ios - 无法以编程方式在 TableView 中自动滚动到特定部分
- amazon-web-services - AWS EventBridge 规则触发两次
- php - .htaccess url 重写一夜之间失败
- karate - 使用 0.9.5.RC4 的 Karate.toMap() 适用于场景,但不适用于场景大纲
- firebase - 在 Firestore 规则中引用变量