Controlling certain parameters of a two y-axes plot
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Zihad Azad
am 4 Feb. 2020
Kommentiert: Star Strider
am 4 Feb. 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;
0 Kommentare
Akzeptierte Antwort
Star Strider
am 4 Feb. 2020
Use gca, not gcf.
3 Kommentare
Star Strider
am 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.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Specifying Target for Graphics Output finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!