I'm trying to plot a filled gaussian in MATLAB2015
(representing the wavefunction of an electron in a Coulomb potential) using the area
function, but an unwanted horizonal line is apearing beneath it. By the way, this line did not appear on MATLAB2011
, but now I do not have this version of MATLAB
.
How can I get rid of this line ?? - Please help.
The code is written below:
close all;clc
x1=-5:0.0001:-0.25;
x2=0.25:0.0001:5;
phi_C_1=-1./abs(x1);
phi_C_2=-1./abs(x2);
figure
plot(x1,phi_C_1,'.-k','MarkerSize',15,'LineWidth',5)
hold on
h_1=plot(x2,phi_C_2,'.-k','MarkerSize',15,'LineWidth',5);
ylim([-4 3])
xlim([-3 3])
x=-1:0.0001:1;
c1=11;c2=-2.7;
y=0.5*exp(-c1*x.^2)+c2;
%axis off
set(gca,'visible','off')
hold on
%plot(x,y,'g.-','MarkerSize',15,'LineWidth',5)
h_2=area(x,y,c2,'FaceColor',[0 1 0],'LineStyle','none',...
'AlignVertexCenters','off');
set(gca,'visible','off')
The figure that is produced is:
This is the area
object's BaseLine
that you're passing as your third input to area
, which you have set as -2.7
. Set the ShowBaseLine
property to 'off'
:
h_2 = area(x, y, c2, 'FaceColor', [0 1 0], 'LineStyle', 'none', ...
'AlignVertexCenters', 'off', 'ShowBaseLine', 'off');