Please add `scroll to zoom` functionality if possible.
hemangjoshi37a opened this issue · comments
for smaller code it is OK to view the flowchart in a small image but for large python file we need to have some library like bokeh to plot the graph so that the content is scroll to zoom and all the nodes are dragable.
To add scroll to zoom functionality in Python, you can use the matplotlib library to create the plot and then use the mpl_connect function to connect the scroll event to a zoom function.
import matplotlib.pyplot as plt
def zoom_function(event):
# get the current x and y limits
cur_xlim = ax.get_xlim()
cur_ylim = ax.get_ylim()
xdata = event.xdata # get event x location
ydata = event.ydata # get event y location
if event.button == 'up':
# deal with zoom in
scale_factor = 1/0.9
elif event.button == 'down':
# deal with zoom out
scale_factor = 0.9
else:
# deal with something that should never happen
scale_factor = 1
print(event.button)
# set new limits
ax.set_xlim([xdata - (xdata - cur_xlim[0])/scale_factor,
xdata + (cur_xlim[1] - xdata)/scale_factor])
ax.set_ylim([ydata - (ydata - cur_ylim[0])/scale_factor,
ydata + (cur_ylim[1] - ydata)/scale_factor])
plt.draw() # force re-draw
fig, ax = plt.subplots()
ax.plot(data)
connect the scroll event to the zoom function
fig.canvas.mpl_connect('scroll_event', zoom_function)
plt.show()
This will create a plot of the data, and when you scroll with the mouse, it will zoom in and out of the plot, centered on the point where you scrolled.
You can adjust the scale factor and other details to suit your needs.
@asu-098 wow awesome thank you brother for helping out.