How to set right y axis ticks using Dearpygui

111 Views Asked by At

I can use set_axis_ticks() to set x axis ticks successfully, but can not set the right y axis. Does anyone know why?

this is my test code, I want to set right y axis ticks, but the left y axis works.

  import dearpygui.dearpygui as dpg
  from math import sin

  dpg.create_context()

  # creating data
  sindatax = []
  sindatay = []
  for i in range(0, 500):
      sindatax.append(i / 1000)
      sindatay.append(0.5 + 0.5 * sin(50 * i / 1000))

  with dpg.window(label="Tutorial"):
      # create plot
      with dpg.plot(label="Line Series", height=400, width=400):
          # optionally create legend
          dpg.add_plot_legend()

          # REQUIRED: create x and y axes
          dpg.add_plot_axis(dpg.mvXAxis, label="x")
          dpg.set_axis_ticks(dpg.last_item(), (("S1", 0), ("S2", 0.5), ("S3", 1)))
          dpg.add_plot_axis(dpg.mvYAxis, label="y", tag="y_axis")
          dpg.add_plot_axis(dpg.mvYAxis, label="y2", tag="y2_axis")
          dpg.set_axis_ticks("y2_axis", (("A1", 0), ("B2", 0.5), ("C3", 1)))

          # series belong to a y axis
          dpg.add_line_series(sindatax, sindatay, label="0.5 + 0.5 * sin(x)", parent="y2_axis")


  dpg.create_viewport(title='Custom Title', width=800, height=600)
  dpg.setup_dearpygui()
  dpg.show_viewport()
  dpg.start_dearpygui()
  dpg.destroy_context()
0

There are 0 best solutions below