Controlling certain parameters of a two y-axes plot

4 vues (au cours des 30 derniers jours)
Zihad Azad
Zihad Azad le 4 Fév 2020
Commenté : Star Strider le 4 Fév 2020
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;

Réponse acceptée

Star Strider
Star Strider le 4 Fév 2020
Note that TickLength is part of Axes Properties, not Figure Properties.
Use gca, not gcf.
  3 commentaires
Zihad Azad
Zihad Azad le 4 Fév 2020
Thanks again. figured it out
Star Strider
Star Strider le 4 Fév 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.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Graphics Object Properties dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by