1

I am trying to plot this curve, and am a little confused on why it looks the way that it does. I would like to plot the curve seen below, but I don't want the lines in the middle and can't figure out why they're there. Could it be because there are 0's in the middle of the vector representing the y values?

plot example

1
  • 1
    The points are plotted In the order you provide them, so yes you have lots of zeros in there. If you want to prune the numbers in some way, then you'll have to do it manually (or sort both arrays together in some way). Commented Apr 5, 2015 at 23:25

2 Answers 2

2

This is just from my phone, so apologies if the formatting is off...

This is happening because you have data with zeros in it. If you want to prune them out in some way, then either you can do it on the reads, or you can sort the data. Something like this should suffice:

x, y = sorted(zip(x, y)) 
Sign up to request clarification or add additional context in comments.

Comments

0

It is already late but I hope it may help to someone. Taken from that answer why my curve fitting plot using matplotlib looks obscured?

You need to sort your X's in ascending order and then use it in plot function. Please bear in mind x and y pairs should be preserved to have correctly drawn curve.

import numpy as np

sorted_indexes = np.argsort(X)
X = X[sorted_indexes]
y = y[sorted_indexes]

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.