0

I am new here and have small experience with matlab.

Here I have a contour plot, with each area between the contours depicted with different colors across a colorbar. I would like to know how to prevent this coloring, and instead just have it a single color.

One more thing, I was wondering that if I want to add a condition or in other words a black color (since no black is in my color bar) like if deltabeta=-2 gamma P make deltabeta black colored is it possible

enter image description here

%gamma=20;
gamma=580;
%P=0.1;
P=0.75;
N=P.*gamma;
lamdazero=1550;
[lamdapump,lamdasignal] = meshgrid(1550:0.1:1700,1550:0.1:1700);
beta3=1.3;
beta4=-8*10^-4;
%beta3=0.06;
%beta4=-2*10^-4;
c=2*pi*3*10^8;
%L=1;
L=0.01;
A0=(1./lamdapump) -(1./lamdazero);
B0=(1./lamdapump) -(1./lamdasignal);
%Linearmismatch=beta2.*c.^2.*(B0).^2;
%beta2=(6*pi.*10^5.*beta3.*A0) +(0.5.*beta4.*A0.^2).*(6.*pi.*10^5)^2;
%Second0=(1./2).*beta2.*(c.^2).*(B0.^2);
Third0=10^-9.*beta3.*(c.^3).*A0.*(B0.^2);
Fourth0=10^-12.*beta4.*(1./2).*c.^4.*(A0.^2).*(B0.^2);
%S4=(10^-12/12).*beta4.*c.^4*(B0.^4);
Fourorder=(10^-12).*c.^4.*beta4.*(1/12).*(B0).^4;
g0=1.1*10^-11;
Aeff=11*10^-12;
PSBS=0.025;
%g0=3.9*10^-9;
%Aeff=14*10^-12;
%PSBS=0.005;
SBS=(g0.*PSBS.*1000)./Aeff ;
deltabeta=Third0+Fourth0+Fourorder;
hold on
 for i=1:1:length(deltabeta)
    for j=1:1:length(deltabeta)
       if(deltabeta(i,j)>=0 || deltabeta(i,j)<=(-4*N))
         test(i,j)=NaN;
       else
          test(i,j)=deltabeta(i,j);
        end
    end
 end
contourf(lamdapump,lamdasignal,test,'ShowText','off');
cmap=[0,0,0];
colormap=cmap;
colorbar
 h = colorbar;
 set(get(h,'title'),'string','\Delta \beta (\gamma P)');
ax = findobj('type','axes');
%set(ax(1),'ytickl',{'-5172.4', '-4310.3', '-3448.3', '-2586.2', '-1724.1',' -862.1', '0', '862.1', '1724.1'})
 xlabel('\lambda_p_u_m_p')
ylabel('\lambda_s_i_g_n_a_l')
title('Contour representing linear phase mismatch for FWM pump power 75 mW and SBS pump power 25 mW ')
hello_there_andy
  • 2,039
  • 2
  • 21
  • 51
  • 1
    Please read [ask], and give us a [MCVE](http://stackoverflow.com/help/mcve) not this huge wall of code! Also, it looks like you're plotting a `contourf` not a line, what do you mean by having the curve with only one colour? – David Feb 13 '15 at 04:51
  • Also please review your tags. This is a pure `matlab` question. `matplotlib` is a python library and unrelated to your problem. – cel Feb 13 '15 at 08:15
  • I run the code (at least it runs) and there is no single curve but many, many curves (2D contour plot). So unless you specify what you really want this question is unclear and cannot get a good answer. Also 95% of the code are unnecessary for the problem. As it is this question helps noone. – NoDataDumpNoContribution Feb 13 '15 at 09:44

1 Answers1

0

Specifying one color

You can set the limits of colors used in the colorbar, by declaring caxis([0, 10]); prior to declaring the h = colorbar;. For example, here I've made everything look a dark blue without removing the contours. In my example 0 is the minimum color value, and 10 is the maximum - you can change these to match your favorite color.

Delete colorbar

You can also delete the colorbar to the right using delete(h)

enter image description here

Code

%gamma=20;
gamma=580;
%P=0.1;
P=0.75;
N=P.*gamma;
lamdazero=1550;
[lamdapump,lamdasignal] = meshgrid(1550:0.1:1700,1550:0.1:1700);
beta3=1.3;
beta4=-8*10^-4;
%beta3=0.06;
%beta4=-2*10^-4;
c=2*pi*3*10^8;
%L=1;
L=0.01;
A0=(1./lamdapump) -(1./lamdazero);
B0=(1./lamdapump) -(1./lamdasignal);
%Linearmismatch=beta2.*c.^2.*(B0).^2;
%beta2=(6*pi.*10^5.*beta3.*A0) +(0.5.*beta4.*A0.^2).*(6.*pi.*10^5)^2;
%Second0=(1./2).*beta2.*(c.^2).*(B0.^2);
Third0=10^-9.*beta3.*(c.^3).*A0.*(B0.^2);
Fourth0=10^-12.*beta4.*(1./2).*c.^4.*(A0.^2).*(B0.^2);
%S4=(10^-12/12).*beta4.*c.^4*(B0.^4);
Fourorder=(10^-12).*c.^4.*beta4.*(1/12).*(B0).^4;
g0=1.1*10^-11;
Aeff=11*10^-12;
PSBS=0.025;
%g0=3.9*10^-9;
%Aeff=14*10^-12;
%PSBS=0.005;
SBS=(g0.*PSBS.*1000)./Aeff ;
deltabeta=Third0+Fourth0+Fourorder;
hold all
 for i=1:1:length(deltabeta)
    for j=1:1:length(deltabeta)
       if(deltabeta(i,j)>=0 || deltabeta(i,j)<=(-4*N))
         test(i,j)=NaN;
       else
          test(i,j)=deltabeta(i,j);
        end
    end
 end
contourf(lamdapump,lamdasignal,test,'ShowText','off');
cmap=[0,0,0];
colormap=cmap;
caxis([0, 10]);  % decide the color of your contour plot here
h = colorbar;
pause(1);
set(get(h,'title'),'string','\Delta \beta (\gamma P)');
ax = findobj('type','axes');
%set(ax(1),'ytickl',{'-5172.4', '-4310.3', '-3448.3', '-2586.2', '-1724.1',' -862.1', '0', '862.1', '1724.1'})
 xlabel('\lambda_p_u_m_p')
ylabel('\lambda_s_i_g_n_a_l')
title('Contour representing linear phase mismatch for FWM pump power 75 mW and SBS pump power 25 mW ')
delete(h);
hello_there_andy
  • 2,039
  • 2
  • 21
  • 51