2

So I have a line plot, and I want to add markers on only some of the points along the plot (I have detected the peaks in the plot and want to mark them). When I plot without the peaks labelled it works as it should, and when I plot the peaks alone it seems to plot them properly, but when I try to plot them on the same plot, the line plot disappears over most of the graph and seems to maybe have become compressed to the side of the plot, if that makes any sense? Here is my code without the peaks plotted and the resulting graph:

 def plotPeaks(file):
      indices, powerSums, times=detectPeaks(file)
      plt.figure(figsize=(100, 10))
      plt.plot(times, powerSums)

Plot without peaks marked

Then when I add the code that should show the peaks, which occur at x-values corresponding to the values stored in the indices, I get this:

def plotPeaks(file):
  indices, powerSums, times=detectPeaks(file)
  plt.figure(figsize=(100, 10))
  plt.plot(times, powerSums)
  for i in indices:
      plt.scatter(i, powerSums[i], marker='o')

Plot with peaks marked

Am I missing something obvious, or is this a glitch that someone has a solution for?

1
  • Does indices store values or indices into times? Commented Jun 12, 2018 at 4:04

1 Answer 1

1

Assuming indices stores indices of times, this should be the last line.

  plt.scatter(times[i], powerSums[i], marker='o')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.