Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why is the plot in matplotlib not continuous?

I’m trying to plot a dataset with solid lines in matplotlib, but it looks strange that it has not a single line instead multiple lines appear in the plot. With the dot marker there is no problem. For comparison the two plots are shown below. Can someone tell me why this is happening?

line plot
dot plot

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

It looks like you have a couple of glitches in the data, manifested as zeros in the x-data. Log of zero goes to negative infinity. You can filter out the zeros with something like:

mask = x.astype(bool)
x = x[mask]
y = y[mask]
plt.semilogx(x, y)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading