saving . . . saved scatter and plot are not same? has been deleted. scatter and plot are not same? has been hidden .
scatter and plot are not same?
Title
Question
I used scatter and plot command as per the exercise given. i plotted them in subplot to have comparison for the given data x=linspace(1,20,100) and y=5x<sup>3</sup>. I  am getting exactly same plot. while in tutorial answer says 'NO'. why this is so?

Python-3.4.3 Other-Types-Of-Plots 07-08 min 10-20 sec 22-04-20, 3:49 p.m. gourihalde@gmail.com

Answers:

<span class="textBox">To combine multiple plots in one graph, use the “hold on” command, such as:</span>
<button class="btn-clipboard" style="margin-right: 3px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; font-size: 11px; font-family: Arial, Helvetica, sans-serif; color: rgb(129, 138, 145); overflow: visible; float: right; border-width: initial; border-style: none; border-color: initial; padding-top: 2px; padding-bottom: 2px;" title="Copy code to clipboard"><span data-pseudo-content="Copy"></span></button>
<span class="textBox" style="white-space: pre;"> plot(1:10)</span>
<span class="textBox" style="white-space: pre;"><span class="textWrapper"> hold </span><span class="textWrapper String" style="color: rgb(160, 32, 240);">on </span></span>
<span class="textBox" style="white-space: pre;"> plot(11:20)</span>
<span class="textBox" style="white-space: pre;"><span class="textWrapper"> hold </span><span class="textWrapper String" style="color: rgb(160, 32, 240);">off</span></span>
22-04-20, 3:56 p.m. arunprasadchamy@gmail.com


<span class="textBox" style="white-space: pre;">snr=0:1:15;</span>
<span class="textBox" style="white-space: pre;"><span class="textWrapper Keyword" style="color: rgb(0, 0, 255);">for </span><span class="textWrapper">ii=1:length(snr)</span></span>
<span class="textBox" style="white-space: pre;"><span class="textWrapper"> x=randint(1,100000); </span><span class="textWrapper Comment" style="color: rgb(34, 139, 34);">% Generating bits</span></span>
<span class="textBox" style="white-space: pre;"><span class="textWrapper"> y=pskmod(x,2); </span><span class="textWrapper Comment" style="color: rgb(34, 139, 34);">% Generating BPSK modulated data</span></span>
<span class="textBox" style="white-space: pre;"><span class="textWrapper"> ynoisy=awgn(y,snr(ii)); </span><span class="textWrapper Comment" style="color: rgb(34, 139, 34);">% Adding AWGN noise to data</span></span>
<span class="textBox" style="white-space: pre;"><span class="textWrapper"> z=pskdemod(ynoisy,2); </span><span class="textWrapper Comment" style="color: rgb(34, 139, 34);">% Demodulating</span></span>
<span class="textBox" style="white-space: pre;"> error(ii)=length(find(x-z~=0));</span>
<span class="textBox" style="white-space: pre;"><span class="textWrapper Keyword" style="color: rgb(0, 0, 255);">end</span></span>
<span class="textBox" style="white-space: pre;">semilogy(snr,error)</span>
<span class="textBox" style="white-space: pre;">hold</span>
<span class="textBox" style="white-space: pre;">snr=0:1:15;</span>
<span class="textBox" style="white-space: pre;"><span class="textWrapper Keyword" style="color: rgb(0, 0, 255);">for </span><span class="textWrapper">ii=1:length(snr)</span></span>
<span class="textBox" style="white-space: pre;"><span class="textWrapper"> x=randint(1,100000); </span><span class="textWrapper Comment" style="color: rgb(34, 139, 34);">% Generating bits</span></span>
<span class="textBox" style="white-space: pre;"><span class="textWrapper"> y=pskmod(x,4); </span><span class="textWrapper Comment" style="color: rgb(34, 139, 34);">% Generating QPSK modulated data</span></span>
<span class="textBox" style="white-space: pre;"><span class="textWrapper"> ynoisy=awgn(y,snr(ii)); </span><span class="textWrapper Comment" style="color: rgb(34, 139, 34);">% Adding AWGN noise to data</span></span>
<span class="textBox" style="white-space: pre;"><span class="textWrapper"> z=pskdemod(ynoisy,4); </span><span class="textWrapper Comment" style="color: rgb(34, 139, 34);">% Demodulating</span></span>
<span class="textBox" style="white-space: pre;"> error(ii)=length(find(x-z~=0));</span>
<span class="textBox" style="white-space: pre;"><span class="textWrapper Keyword" style="color: rgb(0, 0, 255);">end</span></span>
<span class="textBox" style="white-space: pre;">semilogy(snr,error)</span>
<span class="textBox" style="white-space: pre;">grid</span>
22-04-20, 3:57 p.m. arunprasadchamy@gmail.com


No, plot and scatter do not give you the same output graphs even though in your example they may look like the same graph.

In order to understand the difference, try reducing the number of point in x for example use x = linspace(1,20,5) and for the same value of y try plotting the two different graphs.

scatter gives you points, plot gives you a line graph by default
22-04-20, 7:12 p.m. ankitrj.iitb
thanks.
23-04-20, 1:10 a.m. gourihalde@gmail.com

Login to add comment


Log-in to answer to this question.