[Matplotlib-users] Add disconnected lines to a plot

Jerzy Karczmarczuk jerzy.karczmarczuk at unicaen.fr
Mon May 4 05:00:45 EDT 2020


On 04/05/2020 8:30 am, EK Esawi via Matplotlib-users wrote:

> i am trying to use lists instead of numpy plus, it's been a while since i programmed in Python.

Some advice...

1. People who too often complain that they are beginners, are likely to 
remain beginners forever. Beware.

2. If you expect to use matplotlib (or plotly, or pyqtgraph, etc.) 
frequently, master Numpy, or sooner than you think, you will suffer 
very, very much.

3. My previous example was loop-less; this is one of many advantages of 
Numpy. But you can do it in the orthodox way as well.


*from random import random as rn
import matplotlib.pyplot as plt
n=20
nan=float('nan')
a=[rn() for k in range(n)]   # just a silly random example

for j in range(n-2,0,-2):
a.insert(j,nan)# insert your Nans in such a way
plt.plot(a)
*


Best regards

Jerzy Karczmarczuk
/Caen, France/





-- 
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20200504/b9d7c36f/attachment.html>


More information about the Matplotlib-users mailing list