Skip to content

Commit

Permalink
FEAT: Display units option in X and Y axis (#5393)
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuelopez-ansys authored Nov 8, 2024
1 parent 41c9e2d commit b240d8b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
23 changes: 21 additions & 2 deletions src/ansys/aedt/core/visualization/report/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1970,7 +1970,9 @@ def edit_grid(
return self._change_property("Grid", "Grid", props)

@pyaedt_function_handler()
def edit_x_axis(self, font="Arial", font_size=12, italic=False, bold=False, color=(0, 0, 0), label=None):
def edit_x_axis(
self, font="Arial", font_size=12, italic=False, bold=False, color=(0, 0, 0), label=None, display_units=True
):
"""Edit the X-axis settings.
Parameters
Expand All @@ -1988,6 +1990,8 @@ def edit_x_axis(self, font="Arial", font_size=12, italic=False, bold=False, colo
must be an integer in a range from 0 to 255.
label : str, optional
Label for the Y axis. The default is ``None``.
display_units : bool, optional
Whether to display units. The default is ``True``.
Returns
-------
Expand Down Expand Up @@ -2037,6 +2041,8 @@ def edit_x_axis(self, font="Arial", font_size=12, italic=False, bold=False, colo
if label:
props.append(["NAME:Name", "Value:=", label])
props.append(["NAME:Axis Color", "R:=", color[0], "G:=", color[1], "B:=", color[2]])
props.append(["NAME:Display Units", "Value:=", display_units])

return self._change_property("Axis", "AxisX", props)

@pyaedt_function_handler()
Expand Down Expand Up @@ -2157,7 +2163,17 @@ def hide_legend(self, solution_name=True, trace_name=True, variation_key=True, f
return False

@pyaedt_function_handler(axis_name="name")
def edit_y_axis(self, name="Y1", font="Arial", font_size=12, italic=False, bold=False, color=(0, 0, 0), label=None):
def edit_y_axis(
self,
name="Y1",
font="Arial",
font_size=12,
italic=False,
bold=False,
color=(0, 0, 0),
label=None,
display_units=True,
):
"""Edit the Y-axis settings.
Parameters
Expand All @@ -2177,6 +2193,8 @@ def edit_y_axis(self, name="Y1", font="Arial", font_size=12, italic=False, bold=
must be an integer in a range from 0 to 255.
label : str, optional
Label for the Y axis. The default is ``None``.
display_units : bool, optional
Whether to display units. The default is ``True``.
Returns
-------
Expand Down Expand Up @@ -2226,6 +2244,7 @@ def edit_y_axis(self, name="Y1", font="Arial", font_size=12, italic=False, bold=
if label:
props.append(["NAME:Name", "Value:=", label])
props.append(["NAME:Axis Color", "R:=", color[0], "G:=", color[1], "B:=", color[2]])
props.append(["NAME:Display Units", "Value:=", display_units])
return self._change_property("Axis", "Axis" + name, props)

@pyaedt_function_handler(axis_name="name")
Expand Down
8 changes: 6 additions & 2 deletions tests/system/general/test_12_1_PostProcessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,8 +475,12 @@ def test_09m_edit_properties(self):
assert report.edit_grid(major_color=(0, 0, 125))
assert report.edit_grid(major_color=(0, 255, 0))
assert report.edit_grid(style_major="Dot")
assert report.edit_x_axis(font="Courier", font_size=14, italic=True, bold=False, color=(0, 128, 0))
assert report.edit_y_axis(font="Courier", font_size=14, italic=True, bold=False, color=(0, 128, 0))
assert report.edit_x_axis(
font="Bangers", font_size=14, italic=True, bold=False, color=(0, 128, 0), display_units=False
)
assert report.edit_y_axis(
font="Bangers", font_size=14, italic=True, bold=False, color=(0, 128, 0), display_units=False
)
assert report.edit_x_axis(
font="Courier", font_size=14, italic=True, bold=False, color=(0, 128, 0), label="Freq"
)
Expand Down

0 comments on commit b240d8b

Please sign in to comment.