Plot with 2 y-axis with custom tick labels on both
gromanmartin opened this issue · comments
Version of Dear PyGui
Version: 1.10.1
Operating System: Ubuntu 22.04
My Issue/Question
I am trying to create a weather forecast plot with line graph representing temperature and bar graph representing rain values. They share the same x-axis, but I would like the y-axis for temperature to be on the left and show ticks from -30 to 30 and for the y-axis for rain values to be on the right side and be from 0 to 50.
I wanted both axis to share the 0 line, just have different scaling. My idea was to just use set_axis_ticks()
, however I cant seem to adjust the ticks on the right side, since both of the set_axis_ticks
lines adjust only the left one. On Discord I have been told this is will require a fix.
To Reproduce
Steps to reproduce the behavior:
Run the code below and try to change the second call of set_axis_ticks()
values
Expected behavior
set_axis_ticks()
edits the ticks for the axis passed as a argument.
Screenshots/Video
Standalone, minimal, complete and verifiable example
import dearpygui.dearpygui as dpg
dpg.create_context()
dpg.create_viewport(title='Custom Title', width=800, height=580, decorated=True)
dpg.setup_dearpygui()
dpg.show_viewport()
with dpg.window(tag="Primary Window", no_scrollbar=True):
with dpg.plot(label="Today", width=int(800*2/3), height=400):
x_range = [i for i in range(0, 25)]
x_ticks = tuple((f"{x}", x) for x in [3, 6, 9, 12, 15, 18, 21])
dpg.add_plot_axis(dpg.mvXAxis, tag="x_axis_today")
dpg.set_axis_limits("x_axis_today", 0, 24)
dpg.set_axis_ticks("x_axis_today", x_ticks)
dpg.add_plot_axis(dpg.mvYAxis, tag="y_axis_today")
dpg.set_axis_limits("y_axis_today", -25, 25)
dpg.set_axis_ticks("y_axis_today", (("-20", -20), ("20", 20)))
dpg.add_plot_axis(dpg.mvYAxis, tag="y_axis_rain_today")
dpg.set_axis_limits("y_axis_rain_today", -30, 30)
dpg.set_axis_ticks("y_axis_rain_today", (("0", 0), ("10", 10)))
dpg.add_line_series(x_range, 20*[1] + [ -5, -5, -5, 5, 5], parent="y_axis_today")
dpg.add_bar_series(x_range, [10, 3, 4, 4, 3] + 20*[0], parent="y_axis_rain_today")
while dpg.is_dearpygui_running():
dpg.render_dearpygui_frame()
dpg.destroy_context()