ImSoErgodic/py-upset

How can I control the scientific notation that appears as labels on the bars?

VincentLa14 opened this issue · 1 comments

How can I control the scientific notation that appears as labels on the bars?

The 'hack' solution is to edit visualisation.py (in the package).

Edit lines 382 and 385, changing the "%.2g" to a "%.0f" (line 382) and style='sci' to 'plain', and comment out everything after 'y' (line 385).

381 for x, y in zip(self.x_values, inters_sizes):
382 ax.text(x, y + label_vertical_gap, "%.0f" % y,
383 rotation=90, ha='center', va='bottom',size=14)

385 ax.ticklabel_format(style='plain', axis='y')#, scilimits=(0, 4))

This will force it to present the vertical bar plot labels as integers. Repeat the second part on 297 if you want to format the "Set Size" part (lower left corner of figure).

I think there will be a way to do it without editing the package, by getting the figure object and changing the tick formatter, but I struggled with that.

Best solution would be a kwarg the user could pass to define if they want scientific or not at the first stage.