1

I intend to create 2-3 plots shared on a common time axis that can interactively scrolled with a single slider . Also there is one constraint where in sampling frequency is different for each variable but have the same time window.

x - time y1 - values sampled every 1 second y2 - values sampled every 10 seconds y3 - values sampled every 100 seconds 

How can we do this .

Have tried this sample code

import matplotlib.pyplot as plt from ipywidgets import interact %matplotlib inline def f(n): plt.plot([0,1,2],[0,1,n]) plt.show() interact(f,n=(0,10)) 

I want something similar to this , the only change being x and y axis data is constant and the slider widget is used to scroll the graph left and right (x axis here) with a certain time window on the graph display

2
  • 2
    What have you tried so far? This may be problem that has a few different issues, that would be better broken down into individual questions. Is there a place where something isn't behaving as expected? What does you data look like, can you provide a small example? Commented May 29, 2018 at 18:04
  • 1
    You should start writing code and if you have a specific question, you should ask it on SO. You can adapt codes on SO like this one here: stackoverflow.com/q/31001713/8881141 Commented May 29, 2018 at 18:05

2 Answers 2

1

Solved the problem partially for the interactivity bit of it.

X axis is scrollable with the slider movement.

%matplotlib inline from ipywidgets import interactive import matplotlib.pyplot as plt import numpy as np def f(m): plt.figure(2) x = np.linspace(-10, 10, num=1000) plt.plot(x,x) #plt.plot(x, m * x) plt.xlim(m+2, m-2) plt.show() interactive(f, m=(-2.0, 2.0)) 
Sign up to request clarification or add additional context in comments.

Comments

0

Snippet of the implementation below.

  1. Load all the graphs and manipulate only the xlim with plt.xlim(min_x,max_x) with the slider functionality

    selection_range_slider = widgets.SelectionRangeSlider( options=options, index=index, description='Time slider', orientation='horizontal', layout={'width': '1000px'}, continuous_update=False ) #selection_range_slider def print_date_range(date_range): print(date_range) plt.figure(num=None, figsize=(15, 4), dpi=80, facecolor='w', edgecolor='k') min_x=date_range[0] max_x=date_range[1] ax1 = plt.subplot(311) plt.plot(Data_1.Timestamp,Data_1.value,'r') plt.setp(ax1.get_xticklabels(), fontsize=6,visible=False) plt.xlabel('Data_1') ax1.xaxis.set_label_coords(1.05, 0.5) # share x only ax2 = plt.subplot(312, sharex=ax1) plt.plot(Data_2.Timestamp,Data_2.value,'b') # make these tick labels invisible plt.setp(ax2.get_xticklabels(), visible=False) plt.xlabel('Data_2') ax2.xaxis.set_label_coords(1.05, 0.5) # share x and y ax3 = plt.subplot(313, sharex=ax1) plt.plot(Data_3.Timestamp,Data_3.value,'g') ax3.xaxis.set_label_coords(1.05, 0.5) #plt.xlim(0.01, 5.0) plt.xlim(min_x,max_x) plt.show() #plt.xlabel('Data_3') widgets.interact( print_date_range, date_range=selection_range_slider ); 

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.