Set_ylim usage/features

Hello,
I am new to matplotlib and have a question. I have developed a plot of i and q values and used the set_ylim to highlight the changes in values. I can see these peaks in the data but would like to use the data change to perform some data manipulation on specific elements of the data.

Is there an interface to extract the data (…like signal detection)? and use this for further data analysis.

Thanks

Hi, can you please post a sample of your image and code? It’s hard to sort out exactly what you’re asking for…is this static or interactive?

Sorry for the delay… need to make the graphics etc available. New users can only provide 1 graphic…

Here are excerpts from the code and 3 plots…correction 1 plot

Excerpts

  • Get data

  • iq = numpy.fromfile(self.hfile, dtype=self.datatype, count=self.block_length)

  • reals = numpy.array([r.real for r in self.iq])

  • imags = numpy.array([i.imag for i in self.iq])

  • time = numpy.array([i*(1/self.sample_rate) for i in range(len(self.reals))])

Plots

self.sp_iq = self.fig.add_subplot(2,1,1, position=[0.075, 0.14, 0.85, 0.67])

self.sp_iq.set_title(("I&Q"), fontsize=self.label_font_size, fontweight="bold")

self.sp_iq.set_xlabel("Time (s)", fontsize=self.label_font_size, fontweight="bold")

self.sp_iq.set_ylabel("Amplitude (V)", fontsize=self.label_font_size, fontweight="bold")

self.plot_iq = plot(self.time, self.reals, 'bo-', self.time, self.imags, 'ro-')

self.sp_iq.set_ylim( -2.0, 2.0)

self.sp_iq.set_xlim(self.time.min(), self.time.max())

draw()

Update plots

self.plot_iq[0].set_data([self.time, self.reals])

self.plot_iq[1].set_data([self.time, self.imags])

draw()

Fig1a is the signal of interest coming into view

The program works as follows. You can call the python code with a filename. The IQ is plotted on the graph. You can use the < and > to move forward and reverse on the file to see the signal of interest.

I would like to utilize the series data to perform operations when the signal comes into view (fig1a).

I would like to look into the series data to find the start of the signal to process….much like an array.

I could use an FFT to perform this but it is expensive for the CPU. I am hoping to use matplotlib to be able to extract the signal for processing if possible.

Hope this helps.

···

From: Hannah via Matplotlib [mailto:nobody@discourse.matplotlib.org]
Sent: Friday, June 19, 2020 3:55 PM
To: jlabhart@tcsi-tx.com
Subject: [Matplotlib] [Community] Set_ylim usage/features





|

story645
June 19

|

  • | - |

Hi, can you please post a sample of your image and code? It’s hard to sort out exactly what you’re asking for…is this static or interactive?


Visit Topic or reply to this email to respond.

To unsubscribe from these emails, click here.

It looks like you are already using the event system (https://matplotlib.org/3.2.1/users/event_handling.html) and widgets (https://matplotlib.org/3.2.1/api/widgets_api.html?highlight=widgets#module-matplotlib.widgets) to implement the < and > buttons .

From python you have access to the current view limits of the axes (ax.get_xlim()). If you also have access to the original data you passed in you can then use that to extract the current view range to do what ever you want with. You can extract the data back from the Line2D objects created by ax.plot, but it is more reliable to do your own book keeping of the data.

In particular you may find the matplotlib.widgets.SpanSelector useful here (https://matplotlib.org/3.2.1/api/widgets_api.html#matplotlib.widgets.SpanSelector)

That worked….thanks

···

From: tacaswell via Matplotlib [mailto:nobody@discourse.matplotlib.org]
Sent: Tuesday, June 23, 2020 5:44 PM
To: jlabhart@tcsi-tx.com
Subject: [Matplotlib] [Community] Set_ylim usage/features





|

tacaswell
June 23

|

  • | - |

It looks like you are already using the event system (https://matplotlib.org/3.2.1/users/event_handling.html) and widgets (https://matplotlib.org/3.2.1/api/widgets_api.html?highlight=widgets#module-matplotlib.widgets) to implement the < and > buttons .

From python you have access to the current view limits of the axes (ax.get_xlim()). If you also have access to the original data you passed in you can then use that to extract the current view range to do what ever you want with. You can extract the data back from the Line2D objects created by ax.plot, but it is more reliable to do your own book keeping of the data.

In particular you may find the matplotlib.widgets.SpanSelector useful here (https://matplotlib.org/3.2.1/api/widgets_api.html#matplotlib.widgets.SpanSelector)


Visit Topic or reply to this email to respond.

To unsubscribe from these emails, click here.