Skip to content
This repository has been archived by the owner on Mar 11, 2024. It is now read-only.

Commit

Permalink
Correctly handle single-value input
Browse files Browse the repository at this point in the history
  • Loading branch information
a-maliarov committed Apr 28, 2022
1 parent 0def618 commit f7caa04
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions simpleplots/visuals.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def get_x_line_coords(self, x_index: int) -> Coords:
"""Get coordinates of internal grid vertical line."""
_x_offset = self.cell_width * x_index
if len(self.x_major_ticks) == 1:
_x_offset = self.cell_width * 0.5
_x_offset = self.width * 0.5

return Coords(
self.full_h_offset + _x_offset,
Expand All @@ -176,7 +176,7 @@ def get_y_line_coords(self, y_index: int) -> Coords:
"""Get coordinates of internal grid horizontal line."""
_y_offset = self.cell_height * y_index
if len(self.y_major_ticks) == 1:
_y_offset = self.cell_height * 0.5
_y_offset = self.height * 0.5

return Coords(
self.spines.horizontal_offset,
Expand All @@ -189,7 +189,7 @@ def get_x_tick_coords(self, x_index: int) -> Coords:
"""Get coordinates of vertically oriented tick."""
_x_offset = self.cell_width * x_index
if len(self.x_major_ticks) == 1:
_x_offset = self.cell_width * 0.5
_x_offset = self.width * 0.5

return Coords(
self.full_h_offset + _x_offset,
Expand All @@ -202,7 +202,7 @@ def get_y_tick_coords(self, y_index: int) -> Coords:
"""Get coordinates of horizontally oriented tick."""
_y_offset = self.cell_height * y_index
if len(self.y_major_ticks) == 1:
_y_offset = self.cell_height * 0.5
_y_offset = self.height * 0.5

return Coords(
self.spines.horizontal_offset - self.tick_length,
Expand All @@ -216,7 +216,7 @@ def get_x_tick_label_coords(self, x_index: int, text: str,
"""Get coordinates of X tick label."""
_x_offset = self.cell_width * x_index
if len(self.x_major_ticks) == 1:
_x_offset = self.cell_width * 0.5
_x_offset = self.width * 0.5

text_width, text_height = get_text_dimensions(text, font)

Expand All @@ -232,7 +232,7 @@ def get_y_tick_label_coords(self, y_index: int, text: str,
"""Get coordinates of Y tick label."""
_y_offset = self.cell_height * y_index
if len(self.y_major_ticks) == 1:
_y_offset = self.cell_height * 0.5
_y_offset = self.height * 0.5

text_width, text_height = get_text_dimensions(text, font)

Expand All @@ -254,14 +254,14 @@ def get_x_point_coords(self, x_index: int) -> Number:
"""Get coordinates of point on x-axis by X index."""
_x_offset = self.cell_width * x_index
if len(self.x_major_ticks) == 1:
_x_offset = self.cell_width * 0.5
_x_offset = self.width * 0.5
return self.full_h_offset + _x_offset

def get_y_point_coords(self, y_index: int) -> Number:
"""Get coordinates of point on y-axis by Y index."""
_y_offset = self.cell_height * y_index
if len(self.y_major_ticks) == 1:
_y_offset = self.cell_height * 0.5
_y_offset = self.height * 0.5
return self.full_v_offset + self.height - _y_offset

def get_point_coords(self, x_index: int, y_index: int) -> Point:
Expand Down

0 comments on commit f7caa04

Please sign in to comment.