Controlling certain parameters of a two y-axes plot

1 view (last 30 days)
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;

Accepted Answer

Star Strider
Star Strider on 4 Feb 2020
Note that TickLength is part of Axes Properties, not Figure Properties.
Use gca, not gcf.
  3 Comments
Star Strider
Star Strider on 4 Feb 2020
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.

Sign in to comment.

More Answers (0)

Categories

Find more on Specifying Target for Graphics Output in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!