Skip to content

Commit a725725

Browse files
vinnamkimwonjuleee
authored andcommitted
Wrap title text according to plot width (open-edge-platform#769)
* Wrap title text according to plot width Signed-off-by: Kim, Vinnam <[email protected]> * Update CHANGELOG.md Signed-off-by: Kim, Vinnam <[email protected]> Signed-off-by: Kim, Vinnam <[email protected]>
1 parent 5324861 commit a725725

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4141
(<https://github.com/openvinotoolkit/datumaro/pull/767>)
4242

4343
### Changed
44+
- Wrap title text according to its plot width
45+
(<https://github.com/openvinotoolkit/datumaro/pull/769>)
4446
- Get list of subsets and support only Image media type in visualizer
4547
(<https://github.com/openvinotoolkit/datumaro/pull/768>)
4648

datumaro/components/visualizer.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,18 @@ def vis_one_sample(
231231
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
232232
ax.imshow(img)
233233

234-
ax.set_title(f"ID: {id}, Subset={subset}")
234+
width = ax.transAxes.transform_point((1, 0))[0] - ax.transAxes.transform_point((0, 0))[0]
235+
text = ax.set_title(f"ID: {id}, Subset: {subset}", loc="center", wrap=True)
236+
text.__get_wrapped_text = text._get_wrapped_text
237+
238+
def _get_wrapped_text():
239+
wrapped_text = text.__get_wrapped_text()
240+
text._text = wrapped_text
241+
return wrapped_text
242+
243+
text._get_wrapped_text = _get_wrapped_text
244+
text._get_wrap_line_width = lambda: width
245+
235246
ax.set_axis_off()
236247

237248
if self.draw_only_image:

0 commit comments

Comments
 (0)