Skip to content

Commit 0b7cb2d

Browse files
committed
when space set to 1, change to univariate mode
1 parent e324dda commit 0b7cb2d

File tree

1 file changed

+27
-23
lines changed

1 file changed

+27
-23
lines changed

hammock_plot/hammock_plot.py

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,8 @@ def plot(self,
308308
ax, coordinates_dict = self._list_labels(ax, self.height, self.width, self.label)
309309

310310
space = self.space * 10 if label else 0
311+
# when space set to 1, change to univariate mode
312+
space_univar = True if space == 10 else False
311313
bar = self.bar_width * 3.5 / max(data_point_numbers)
312314

313315
if self.shape == "parallelogram":
@@ -372,35 +374,37 @@ def plot(self,
372374
label_rectangle_widths.append(label_rectangle_width)
373375

374376
if not hi_var:
375-
ax = figure_type.plot(ax, left_center_pts, right_center_pts, widths, default_color)
377+
if not space_univar:
378+
ax = figure_type.plot(ax, left_center_pts, right_center_pts, widths, default_color)
376379
if label_rectangle:
377380
ax = label_rectangle_painter.plot(ax, label_rectangle_left_center_pts, label_rectangle_right_center_pts, label_rectangle_widths,label_rectangle_default_color)
378381
else:
379382
width_color_total = [0] * len(widths)
380383
label_rectangle_width_color_total = [0] * len(coordinates_dict)
381384
xs, ys = figure_type.get_coordinates(left_center_pts, right_center_pts, widths)
382-
for color in self.color_lst:
383-
widths_color, ratio_color_centers = [], []
384-
index = 0
385-
for col in pair_dict_lst_color:
386-
for k, v in col.items():
387-
left_label = k[0]
388-
right_label = k[1]
389-
if v.get(color):
390-
width_temp = bar * v.get(color)
391-
if self.min_bar_width and width_temp <= self.min_bar_width:
392-
width_temp = self.min_bar_width
393-
else:
394-
width_temp = 0
395-
396-
widths_color.append(width_temp)
397-
ratio_color_centers.append((width_color_total[index] + width_temp / 2) / widths[index])
398-
width_color_total[index] += width_temp
399-
index += 1
400-
401-
color_left_center_pts, color_right_center_pts = figure_type.get_center_highlight(xs, ys,
402-
ratio_color_centers)
403-
ax = figure_type.plot(ax, color_left_center_pts, color_right_center_pts, widths_color, color)
385+
if not space_univar:
386+
for color in self.color_lst:
387+
widths_color, ratio_color_centers = [], []
388+
index = 0
389+
for col in pair_dict_lst_color:
390+
for k, v in col.items():
391+
left_label = k[0]
392+
right_label = k[1]
393+
if v.get(color):
394+
width_temp = bar * v.get(color)
395+
if self.min_bar_width and width_temp <= self.min_bar_width:
396+
width_temp = self.min_bar_width
397+
else:
398+
width_temp = 0
399+
400+
widths_color.append(width_temp)
401+
ratio_color_centers.append((width_color_total[index] + width_temp / 2) / widths[index])
402+
width_color_total[index] += width_temp
403+
index += 1
404+
405+
color_left_center_pts, color_right_center_pts = figure_type.get_center_highlight(xs, ys,
406+
ratio_color_centers)
407+
ax = figure_type.plot(ax, color_left_center_pts, color_right_center_pts, widths_color, color)
404408

405409
# always remember that color list was reversed, so the first color is the default color
406410
if label_rectangle:

0 commit comments

Comments
 (0)