Controlling certain parameters of a two y-axes plot
1 次查看(过去 30 天)
显示 更早的评论
Hi there,
I am plotting a graph that has two y-axes:
However, I need to control certain parameters of this graph. For example, I need to change the ticklengths but the
set(gcf,'TickLength',[.014 .014]);
line is not working. Also, I would like to change the plot colors. I do not like the default colors assigned by matlab. How should I do that? Thanks in advance
The codes and files are attached herewith:
clc; clear all;
load output;
load gain;
load SPR_gain;
yyaxis left
p1=plot(lambda*1e9,G,'linewidth',3);
xlabel('Wavelength \rm(nm)'), ylabel('Gain \rm(dB)');
xlim([770 920]);ylim([0 25]);
legend boxoff;
yyaxis right
p2=plot(l*1e9,T_gain*1e15,'-',l*1e9,T_op*1e15,'-.','linewidth',2.5);
set(gcf,'renderer','painters');
ylabel('Intensity \rm(\muW/cm^2)');
xlim([770 920]); ylim([0 4]);
legend({'Gain Lineshape of IR-140','SPP mode and hole scattering','Output Emission'},'Position',[0.34 0.71 0.08 0.08],'FontSize',18);
FS='Fontsize';
fs=20;
FN='Fontname';
fn='Times New Roman';
set(findall(gcf,'type','axes'),FS,fs,FN,fn);
set(findall(gcf,'type','text'),FS,fs,FN,fn);
% set(gcf,'TickLength',[.014 .014]);
set(gcf,'renderer','painters');
grid off
x0=100;
y0=100;
width=700;
height=500;
set(gcf,'units','pixels','position',[x0,y0,width,height]);
% print -depsc spectral_decomp.eps;
0 个评论
采纳的回答
Star Strider
2020-2-4
Use gca, not gcf.
3 个评论
Star Strider
2020-2-4
Experiment with this in your code:
x = 1:10;
y1 = rand(1, 10);
y2 = rand(1, 10)+1;
figure
yyaxis left;
plot(x, y1)
AxL = gca;
yyaxis right
plot(x, y2)
AxR = gca;
AxL.TickLength = [0.15 0.2];
AxR.YColor = 'g';
For more optionsdd, see: Modify Properties of Charts with Two y-Axes, in addition to Axes Properties, that I already linked to.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Specifying Target for Graphics Output 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!