Hello. There is such a schedule: enter image description here I need to understand how the argument in the slider works in order to try to customize the code for myself. In this particular case, I need to implement scaling on the slider. So that the distance between the points along the Y axis would be either huge or everything would merge into one point. I managed to achieve this - but it all happens in 2 steps for some reason. And I need to understand why. I would like it to happen smoothly and scaling so that you can adjust it a little differently .. (extreme limits) I just did not try it already - nothing works correctly in the mind. )

Question: how can this be implemented with the slider? I need the scaling to occur by 2 values ​​(the highest point and the lowest)

PS Skeleton of incorrectly working code, so far it looks like this for me:

aycolor = 'blue' ax_y_pos = plt.axes([0.086, 0.894, 0.828, 0.022], axisbg=aycolor) y_pos = Slider(ax_y_pos, '', 0, 1, valfmt='%d', valinit=max_value(self.high) + (max_value(self.high) * 0.0022), color='green') y_pos.valtext.set_visible(False) def update(val): pos = int(y_pos.val) ax.set_ylim(min_value(self.low), max_value(self.high)) fig.canvas.draw_idle() cid = y_pos.on_changed(update) ax.set_ylim(min_value(self.low) - (min_value(self.low) * 0.0022), max_value(self.high) + (max_value(self.high) * 0.0022)) 

I would appreciate any help ..

    1 answer 1

    It was possible to resolve the issue on their own as follows:

      candlesticks_in_screen = 25 start_slider_y = 0.1 # вычисляем минимальный low среди свечек, которые помещаются в одном экране def min_value(self_low): self_low = self_low[-candlesticks_in_screen:] low_min_value = [self_low[0]] for search_min_value in self_low: if search_min_value < low_min_value[0]: low_min_value.clear() low_min_value.append(search_min_value) return low_min_value[0] # вычисляем максимальный high среди свечек, которые помещаются в одном экране def max_value(self_high): self_high = self_high[-candlesticks_in_screen:] high_max_value = [self_high[0]] for search_max_value in self_high: if search_max_value > high_max_value[0]: high_max_value.clear() high_max_value.append(search_max_value) return high_max_value[0] aycolor = 'orange' ax_y_pos = plt.axes([0.086, 0.894, 0.828, 0.022], axisbg=aycolor) y_pos = Slider(ax_y_pos, '', 0, 1, valfmt='%d', valinit=start_slider_y, color='green') y_pos.valtext.set_visible(False) def update(val): pos = int(y_pos.val) # print('pos = ', pos,'\n', 'val = ', val) ax.set_ylim(min_value(self.low) - (val / 100), max_value(self.high) + (val / 100)) # print('\n', 'ax.set_ylim = ', ax.set_ylim(min_value(self.low) - (val / 100), # max_value(self.high) + (val / 100)), '\n', 'val = ', val) fig.canvas.draw_idle() cid = y_pos.on_changed(update) ax.set_ylim(min_value(self.low) - start_slider_y / 100, max_value(self.high) + start_slider_y / 100) # ---------- Slider(Scroll Bar) Axex y end ------------------