<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">---------- Forwarded message ---------<br>From: <strong class="gmail_sendername" dir="auto">binsha s</strong> <span dir="ltr"><<a href="mailto:binshasrn@gmail.com">binshasrn@gmail.com</a>></span><br>Date: Tue, May 21, 2019 at 10:20 AM<br>Subject: Multiple plotting using loops in python<br>To: <<a href="mailto:pyqt-request@riverbankcomputing.com">pyqt-request@riverbankcomputing.com</a>><br></div><br><br><div dir="ltr">
<div class="m_-7855795486154935263gmail-post-text">
<p>I have x data as:</p>
<pre class="m_-7855795486154935263gmail-lang-py m_-7855795486154935263gmail-prettyprint m_-7855795486154935263gmail-prettyprinted"><code><span class="m_-7855795486154935263gmail-pln">x_data</span><span class="m_-7855795486154935263gmail-pun">:[[-</span><span class="m_-7855795486154935263gmail-lit">210.99</span><span class="m_-7855795486154935263gmail-pun">],[</span><span class="m_-7855795486154935263gmail-lit">210.666</span><span class="m_-7855795486154935263gmail-pun">],[</span><span class="m_-7855795486154935263gmail-lit">553.211</span><span class="m_-7855795486154935263gmail-pun">],[</span><span class="m_-7855795486154935263gmail-lit">123.332</span><span class="m_-7855795486154935263gmail-pun">],.....[</span><span class="m_-7855795486154935263gmail-lit">234.121</span><span class="m_-7855795486154935263gmail-pun">]]</span></code></pre>
<p>If I have <code>n</code> columns then <code>y1,y2,...yn</code> should be plotted with <code>x_data</code>
so that within one graph n data can be visualized. I am also using
slideshow for visualizing a clear view of each column data. For
appearing data as a slideshow I am splitting each data of <code>y1, y2,...yn</code> into 5 data with <code>x_data</code>.</p>
<p>For example if I have columns as Col-1 and Col-2 then:</p>
<pre class="m_-7855795486154935263gmail-lang-py m_-7855795486154935263gmail-prettyprint m_-7855795486154935263gmail-prettyprinted"><code><span class="m_-7855795486154935263gmail-pln">y1</span><span class="m_-7855795486154935263gmail-pun">=[[</span><span class="m_-7855795486154935263gmail-lit">10.556</span><span class="m_-7855795486154935263gmail-pun">],[</span><span class="m_-7855795486154935263gmail-lit">12.5687</span><span class="m_-7855795486154935263gmail-pun">],[</span><span class="m_-7855795486154935263gmail-lit">44.5568</span><span class="m_-7855795486154935263gmail-pun">],...[</span><span class="m_-7855795486154935263gmail-lit">66.6679</span><span class="m_-7855795486154935263gmail-pun">]]</span><span class="m_-7855795486154935263gmail-pln">
y2</span><span class="m_-7855795486154935263gmail-pun">=[[</span><span class="m_-7855795486154935263gmail-lit">10.4075</span><span class="m_-7855795486154935263gmail-pun">],[</span><span class="m_-7855795486154935263gmail-lit">12.5456</span><span class="m_-7855795486154935263gmail-pun">],[</span><span class="m_-7855795486154935263gmail-lit">23.5456</span><span class="m_-7855795486154935263gmail-pun">],...[</span><span class="m_-7855795486154935263gmail-lit">76.567</span><span class="m_-7855795486154935263gmail-pun">]]</span></code></pre>
<p>The split data of y1, y2 with <code>x_data</code> should be plotted multiple and appear as slideshow. For that I combined into one array as </p>
<pre class="m_-7855795486154935263gmail-lang-py m_-7855795486154935263gmail-prettyprint m_-7855795486154935263gmail-prettyprinted"><code><span class="m_-7855795486154935263gmail-pln"> splitArraylist</span><span class="m_-7855795486154935263gmail-pun">=[</span><span class="m_-7855795486154935263gmail-pln">array</span><span class="m_-7855795486154935263gmail-pun">[[</span><span class="m_-7855795486154935263gmail-lit">10.556</span><span class="m_-7855795486154935263gmail-pun">],[</span><span class="m_-7855795486154935263gmail-lit">12.5687</span><span class="m_-7855795486154935263gmail-pun">],[</span><span class="m_-7855795486154935263gmail-lit">44.5568</span><span class="m_-7855795486154935263gmail-pun">],...[</span><span class="m_-7855795486154935263gmail-lit">66.6679</span><span class="m_-7855795486154935263gmail-pun">]]),</span><span class="m_-7855795486154935263gmail-pln">array</span><span class="m_-7855795486154935263gmail-pun">([[</span><span class="m_-7855795486154935263gmail-lit">10.4075</span><span class="m_-7855795486154935263gmail-pun">],[</span><span class="m_-7855795486154935263gmail-lit">12.5456</span><span class="m_-7855795486154935263gmail-pun">],[</span><span class="m_-7855795486154935263gmail-lit">23.5456</span><span class="m_-7855795486154935263gmail-pun">],...[</span><span class="m_-7855795486154935263gmail-lit">76.567</span><span class="m_-7855795486154935263gmail-pun">]])]</span></code></pre>
<p>What I have tried is:</p>
<pre class="m_-7855795486154935263gmail-lang-py m_-7855795486154935263gmail-prettyprint m_-7855795486154935263gmail-prettyprinted"><code><span class="m_-7855795486154935263gmail-pln"> checked_list</span><span class="m_-7855795486154935263gmail-pun">=[</span><span class="m_-7855795486154935263gmail-lit">1</span><span class="m_-7855795486154935263gmail-pun">,</span><span class="m_-7855795486154935263gmail-lit">2</span><span class="m_-7855795486154935263gmail-pun">]</span><span class="m_-7855795486154935263gmail-pln">
gvalue</span><span class="m_-7855795486154935263gmail-pun">=</span><span class="m_-7855795486154935263gmail-lit">5</span><span class="m_-7855795486154935263gmail-pln">
self</span><span class="m_-7855795486154935263gmail-pun">.</span><span class="m_-7855795486154935263gmail-pln">XY</span><span class="m_-7855795486154935263gmail-pun">(</span><span class="m_-7855795486154935263gmail-pln">splitArraylist</span><span class="m_-7855795486154935263gmail-pun">)</span><span class="m_-7855795486154935263gmail-pln">
</span><span class="m_-7855795486154935263gmail-kwd">def</span><span class="m_-7855795486154935263gmail-pln"> XY</span><span class="m_-7855795486154935263gmail-pun">(</span><span class="m_-7855795486154935263gmail-pln">self</span><span class="m_-7855795486154935263gmail-pun">,</span><span class="m_-7855795486154935263gmail-pln">y</span><span class="m_-7855795486154935263gmail-pun">):</span><span class="m_-7855795486154935263gmail-pln">
y1</span><span class="m_-7855795486154935263gmail-pun">=</span><span class="m_-7855795486154935263gmail-pln">np</span><span class="m_-7855795486154935263gmail-pun">.</span><span class="m_-7855795486154935263gmail-pln">array</span><span class="m_-7855795486154935263gmail-pun">(</span><span class="m_-7855795486154935263gmail-pln">y</span><span class="m_-7855795486154935263gmail-pun">)</span><span class="m_-7855795486154935263gmail-pln">
</span><span class="m_-7855795486154935263gmail-kwd">for</span><span class="m_-7855795486154935263gmail-pln"> i </span><span class="m_-7855795486154935263gmail-kwd">in</span><span class="m_-7855795486154935263gmail-pln"> range</span><span class="m_-7855795486154935263gmail-pun">(</span><span class="m_-7855795486154935263gmail-pln">len</span><span class="m_-7855795486154935263gmail-pun">(</span><span class="m_-7855795486154935263gmail-pln">checked_list</span><span class="m_-7855795486154935263gmail-pun">)):</span><span class="m_-7855795486154935263gmail-pln">
self</span><span class="m_-7855795486154935263gmail-pun">.</span><span class="m_-7855795486154935263gmail-pln">splitXy</span><span class="m_-7855795486154935263gmail-pun">(</span><span class="m_-7855795486154935263gmail-pln">y1</span><span class="m_-7855795486154935263gmail-pun">[</span><span class="m_-7855795486154935263gmail-pln">i</span><span class="m_-7855795486154935263gmail-pun">][</span><span class="m_-7855795486154935263gmail-lit">0</span><span class="m_-7855795486154935263gmail-pun">])</span><span class="m_-7855795486154935263gmail-pln">
self</span><span class="m_-7855795486154935263gmail-pun">.</span><span class="m_-7855795486154935263gmail-pln">graphXY</span><span class="m_-7855795486154935263gmail-pun">()</span><span class="m_-7855795486154935263gmail-pln">
</span><span class="m_-7855795486154935263gmail-kwd">def</span><span class="m_-7855795486154935263gmail-pln"> splitXy</span><span class="m_-7855795486154935263gmail-pun">(</span><span class="m_-7855795486154935263gmail-pln">self</span><span class="m_-7855795486154935263gmail-pun">,</span><span class="m_-7855795486154935263gmail-pln">res</span><span class="m_-7855795486154935263gmail-pun">):</span><span class="m_-7855795486154935263gmail-pln">
current_iter</span><span class="m_-7855795486154935263gmail-pun">=</span><span class="m_-7855795486154935263gmail-lit">0</span><span class="m_-7855795486154935263gmail-pln">
</span><span class="m_-7855795486154935263gmail-com">#Splitting each data of y1 into 5 graphs</span><span class="m_-7855795486154935263gmail-pln">
</span><span class="m_-7855795486154935263gmail-kwd">for</span><span class="m_-7855795486154935263gmail-pln"> j </span><span class="m_-7855795486154935263gmail-kwd">in</span><span class="m_-7855795486154935263gmail-pln"> range</span><span class="m_-7855795486154935263gmail-pun">(</span><span class="m_-7855795486154935263gmail-pln">gvalue</span><span class="m_-7855795486154935263gmail-pun">):</span><span class="m_-7855795486154935263gmail-pln">
x_data</span><span class="m_-7855795486154935263gmail-pun">.</span><span class="m_-7855795486154935263gmail-pln">append</span><span class="m_-7855795486154935263gmail-pun">(</span><span class="m_-7855795486154935263gmail-pln">x</span><span class="m_-7855795486154935263gmail-pun">[</span><span class="m_-7855795486154935263gmail-pln">current_iter</span><span class="m_-7855795486154935263gmail-pun">:</span><span class="m_-7855795486154935263gmail-pln">current_iter</span><span class="m_-7855795486154935263gmail-pun">+</span><span class="m_-7855795486154935263gmail-pln">iters</span><span class="m_-7855795486154935263gmail-pun">])</span><span class="m_-7855795486154935263gmail-pln">
y_data</span><span class="m_-7855795486154935263gmail-pun">.</span><span class="m_-7855795486154935263gmail-pln">append</span><span class="m_-7855795486154935263gmail-pun">(</span><span class="m_-7855795486154935263gmail-pln">res</span><span class="m_-7855795486154935263gmail-pun">[</span><span class="m_-7855795486154935263gmail-pln">current_iter</span><span class="m_-7855795486154935263gmail-pun">:</span><span class="m_-7855795486154935263gmail-pln">current_iter</span><span class="m_-7855795486154935263gmail-pun">+</span><span class="m_-7855795486154935263gmail-pln">iters</span><span class="m_-7855795486154935263gmail-pun">])</span><span class="m_-7855795486154935263gmail-pln">
current_iter</span><span class="m_-7855795486154935263gmail-pun">=</span><span class="m_-7855795486154935263gmail-pln">current_iter</span><span class="m_-7855795486154935263gmail-pun">+</span><span class="m_-7855795486154935263gmail-pln">iters
</span><span class="m_-7855795486154935263gmail-kwd">def</span><span class="m_-7855795486154935263gmail-pln"> graphXY</span><span class="m_-7855795486154935263gmail-pun">(</span><span class="m_-7855795486154935263gmail-pln">self</span><span class="m_-7855795486154935263gmail-pun">):</span><span class="m_-7855795486154935263gmail-pln">
</span><span class="m_-7855795486154935263gmail-kwd">global</span><span class="m_-7855795486154935263gmail-pln"> cp</span><span class="m_-7855795486154935263gmail-pun">,</span><span class="m_-7855795486154935263gmail-pln"> loopbool
</span><span class="m_-7855795486154935263gmail-kwd">for</span><span class="m_-7855795486154935263gmail-pln"> j </span><span class="m_-7855795486154935263gmail-kwd">in</span><span class="m_-7855795486154935263gmail-pln"> range</span><span class="m_-7855795486154935263gmail-pun">(</span><span class="m_-7855795486154935263gmail-pln">len</span><span class="m_-7855795486154935263gmail-pun">(</span><span class="m_-7855795486154935263gmail-pln">checked_list</span><span class="m_-7855795486154935263gmail-pun">)*</span><span class="m_-7855795486154935263gmail-pln">gvalue</span><span class="m_-7855795486154935263gmail-pun">):</span><span class="m_-7855795486154935263gmail-pln">
</span><span class="m_-7855795486154935263gmail-kwd">if</span><span class="m_-7855795486154935263gmail-pln"> loopbool </span><span class="m_-7855795486154935263gmail-pun">==</span><span class="m_-7855795486154935263gmail-pln"> </span><span class="m_-7855795486154935263gmail-kwd">True</span><span class="m_-7855795486154935263gmail-pun">:</span><span class="m_-7855795486154935263gmail-pln">
n_graphs</span><span class="m_-7855795486154935263gmail-pun">.</span><span class="m_-7855795486154935263gmail-pln">append</span><span class="m_-7855795486154935263gmail-pun">(</span><span class="m_-7855795486154935263gmail-pln">str</span><span class="m_-7855795486154935263gmail-pun">(</span><span class="m_-7855795486154935263gmail-pln">j </span><span class="m_-7855795486154935263gmail-pun">+</span><span class="m_-7855795486154935263gmail-pln"> </span><span class="m_-7855795486154935263gmail-lit">1</span><span class="m_-7855795486154935263gmail-pun">))</span><span class="m_-7855795486154935263gmail-pln">
cp </span><span class="m_-7855795486154935263gmail-pun">=</span><span class="m_-7855795486154935263gmail-pln"> int</span><span class="m_-7855795486154935263gmail-pun">(</span><span class="m_-7855795486154935263gmail-pln">n_graphs</span><span class="m_-7855795486154935263gmail-pun">[</span><span class="m_-7855795486154935263gmail-pln">len</span><span class="m_-7855795486154935263gmail-pun">(</span><span class="m_-7855795486154935263gmail-pln">n_graphs</span><span class="m_-7855795486154935263gmail-pun">)-</span><span class="m_-7855795486154935263gmail-pln"> </span><span class="m_-7855795486154935263gmail-lit">1</span><span class="m_-7855795486154935263gmail-pun">])</span><span class="m_-7855795486154935263gmail-pln">
</span><span class="m_-7855795486154935263gmail-com">#PLotting each set of data in y1 and y2 with x_data</span><span class="m_-7855795486154935263gmail-pln">
self</span><span class="m_-7855795486154935263gmail-pun">.</span><span class="m_-7855795486154935263gmail-pln">plotDraw</span><span class="m_-7855795486154935263gmail-pun">(</span><span class="m_-7855795486154935263gmail-pln">x_data</span><span class="m_-7855795486154935263gmail-pun">[</span><span class="m_-7855795486154935263gmail-pln">j</span><span class="m_-7855795486154935263gmail-pun">],</span><span class="m_-7855795486154935263gmail-pln">y_data</span><span class="m_-7855795486154935263gmail-pun">[</span><span class="m_-7855795486154935263gmail-pln">j</span><span class="m_-7855795486154935263gmail-pun">])</span><span class="m_-7855795486154935263gmail-pln">
loop </span><span class="m_-7855795486154935263gmail-pun">=</span><span class="m_-7855795486154935263gmail-pln"> </span><span class="m_-7855795486154935263gmail-typ">QEventLoop</span><span class="m_-7855795486154935263gmail-pun">()</span><span class="m_-7855795486154935263gmail-pln">
</span><span class="m_-7855795486154935263gmail-typ">QTimer</span><span class="m_-7855795486154935263gmail-pun">.</span><span class="m_-7855795486154935263gmail-pln">singleShot</span><span class="m_-7855795486154935263gmail-pun">(</span><span class="m_-7855795486154935263gmail-pln">int</span><span class="m_-7855795486154935263gmail-pun">(</span><span class="m_-7855795486154935263gmail-pln">sec_value</span><span class="m_-7855795486154935263gmail-pun">),</span><span class="m_-7855795486154935263gmail-pln"> loop</span><span class="m_-7855795486154935263gmail-pun">.</span><span class="m_-7855795486154935263gmail-pln">quit</span><span class="m_-7855795486154935263gmail-pun">)</span><span class="m_-7855795486154935263gmail-pln">
loop</span><span class="m_-7855795486154935263gmail-pun">.</span><span class="m_-7855795486154935263gmail-pln">exec_</span><span class="m_-7855795486154935263gmail-pun">()</span><span class="m_-7855795486154935263gmail-pln">
j </span><span class="m_-7855795486154935263gmail-pun">=</span><span class="m_-7855795486154935263gmail-pln"> j </span><span class="m_-7855795486154935263gmail-pun">+</span><span class="m_-7855795486154935263gmail-pln"> </span><span class="m_-7855795486154935263gmail-lit">1</span><span class="m_-7855795486154935263gmail-pln">
</span><span class="m_-7855795486154935263gmail-kwd">def</span><span class="m_-7855795486154935263gmail-pln"> plotDraw</span><span class="m_-7855795486154935263gmail-pun">(</span><span class="m_-7855795486154935263gmail-pln">self</span><span class="m_-7855795486154935263gmail-pun">,</span><span class="m_-7855795486154935263gmail-pln"> x0</span><span class="m_-7855795486154935263gmail-pun">,</span><span class="m_-7855795486154935263gmail-pln"> y0</span><span class="m_-7855795486154935263gmail-pun">):</span><span class="m_-7855795486154935263gmail-pln">
self</span><span class="m_-7855795486154935263gmail-pun">.</span><span class="m_-7855795486154935263gmail-typ">MplWidget</span><span class="m_-7855795486154935263gmail-pun">.</span><span class="m_-7855795486154935263gmail-pln">canvas</span><span class="m_-7855795486154935263gmail-pun">.</span><span class="m_-7855795486154935263gmail-pln">axes</span><span class="m_-7855795486154935263gmail-pun">.</span><span class="m_-7855795486154935263gmail-pln">clear</span><span class="m_-7855795486154935263gmail-pun">()</span><span class="m_-7855795486154935263gmail-pln">
self</span><span class="m_-7855795486154935263gmail-pun">.</span><span class="m_-7855795486154935263gmail-typ">MplWidget</span><span class="m_-7855795486154935263gmail-pun">.</span><span class="m_-7855795486154935263gmail-pln">canvas</span><span class="m_-7855795486154935263gmail-pun">.</span><span class="m_-7855795486154935263gmail-pln">axes</span><span class="m_-7855795486154935263gmail-pun">.</span><span class="m_-7855795486154935263gmail-pln">plot</span><span class="m_-7855795486154935263gmail-pun">(</span><span class="m_-7855795486154935263gmail-pln">x0</span><span class="m_-7855795486154935263gmail-pun">,</span><span class="m_-7855795486154935263gmail-pln"> y0</span><span class="m_-7855795486154935263gmail-pun">)</span><span class="m_-7855795486154935263gmail-pln">
self</span><span class="m_-7855795486154935263gmail-pun">.</span><span class="m_-7855795486154935263gmail-typ">MplWidget</span><span class="m_-7855795486154935263gmail-pun">.</span><span class="m_-7855795486154935263gmail-pln">canvas</span><span class="m_-7855795486154935263gmail-pun">.</span><span class="m_-7855795486154935263gmail-pln">axes</span><span class="m_-7855795486154935263gmail-pun">.</span><span class="m_-7855795486154935263gmail-pln">legend</span><span class="m_-7855795486154935263gmail-pun">((</span><span class="m_-7855795486154935263gmail-str">'cosinus'</span><span class="m_-7855795486154935263gmail-pun">,</span><span class="m_-7855795486154935263gmail-pln"> </span><span class="m_-7855795486154935263gmail-str">'sinus'</span><span class="m_-7855795486154935263gmail-pun">),</span><span class="m_-7855795486154935263gmail-pln"> loc</span><span class="m_-7855795486154935263gmail-pun">=</span><span class="m_-7855795486154935263gmail-str">'upper right'</span><span class="m_-7855795486154935263gmail-pun">)</span><span class="m_-7855795486154935263gmail-pln">
self</span><span class="m_-7855795486154935263gmail-pun">.</span><span class="m_-7855795486154935263gmail-typ">MplWidget</span><span class="m_-7855795486154935263gmail-pun">.</span><span class="m_-7855795486154935263gmail-pln">canvas</span><span class="m_-7855795486154935263gmail-pun">.</span><span class="m_-7855795486154935263gmail-pln">axes</span><span class="m_-7855795486154935263gmail-pun">.</span><span class="m_-7855795486154935263gmail-pln">set_title</span><span class="m_-7855795486154935263gmail-pun">(</span><span class="m_-7855795486154935263gmail-str">'Signal'</span><span class="m_-7855795486154935263gmail-pun">)</span><span class="m_-7855795486154935263gmail-pln">
self</span><span class="m_-7855795486154935263gmail-pun">.</span><span class="m_-7855795486154935263gmail-typ">MplWidget</span><span class="m_-7855795486154935263gmail-pun">.</span><span class="m_-7855795486154935263gmail-pln">canvas</span><span class="m_-7855795486154935263gmail-pun">.</span><span class="m_-7855795486154935263gmail-pln">draw</span><span class="m_-7855795486154935263gmail-pun">()</span></code></pre>
<p>Currently data is plotting one after the other data. That is first
set of data y1 and is split and plotted. Then next column y2 is plotted
and appear as a slideshow.</p>
<p>I actually want y1 and y2 data to occur in single graph and appear as
a slideshow. (i.e.) For the first graph of slideshow first split data
of y1 and y2 occur in one graph then second split data of y1 and y2 ...
likewise 5 graphs should be there.</p>
<p>How to do I do this? How can multiple plotting be achieved using loops and arrays?</p>
</div>
</div>
</div></div>