Skip to content

Commit

Permalink
added drawing mode feature to draw lines on plot example
Browse files Browse the repository at this point in the history
  • Loading branch information
my1e5 committed Apr 23, 2024
1 parent c5254df commit 05ec998
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions plots/plot_draw_lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ def unlock_axis(axis):
dpg.set_axis_limits_auto(axis)

def plot_mouse_click_callback():
if not dpg.get_value(drawing_mode):
return
lock_axis(xaxis), lock_axis(yaxis)
dpg.delete_item(xaxis, children_only=True) # delete the previous line series

Expand All @@ -33,6 +35,7 @@ def plot_mouse_click_callback():

with dpg.window():
dpg.add_text("Left click and drag on the plot to add a line series.\nIt only works if you drag left to right.")
drawing_mode = dpg.add_checkbox(label="Drawing mode", default_value=True)
with dpg.plot(anti_aliased=True) as plot:
xaxis = dpg.add_plot_axis(dpg.mvXAxis)
yaxis = dpg.add_plot_axis(dpg.mvYAxis)
Expand Down

0 comments on commit 05ec998

Please sign in to comment.