File Exchange

image thumbnail

bordertext( varargin )

version 1.5.0.0 (25.6 KB) by Jan de Wilde
Place text on borders of the figure, border of the subplots, on the inner-side or outer-side.

1 Download

Updated 23 Oct 2016

View License

Editor's Note: This file was selected as MATLAB Central Pick of the Week

Place text on borders of the figure, border of the subplots, on the inner-side or outer-side. Also control the most important text-properties with one simple FormatString.
Text stays on the borders, even while zooming, panning, etc.
Try 'bordertext' without arguments to see the demo (figure is added as screenshot)

Cite As

Jan de Wilde (2019). bordertext( varargin ) (https://www.mathworks.com/matlabcentral/fileexchange/41475-bordertext-varargin), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (15)

arnold

one thing I did discover: when applying 'axis image' or 'axis square" to axis, even before using borderplot, the text is not aligned properly, always reaching out of the bounds of the axis.
Any ideas?

arnold

never mind my earlier comment, I see you have added an offsetx and offsety. I don't quite understand what margin does?!
regards
Arnold

arnold

Hi Jan,
I've discovered a strange behavior. If I export the figure the bordertext (innertopleft i.e.) is wrongly positioned (goes over the edge of the plot). If I move the mouse over the figure, the bordertext is repositioned correctly.
I tried to refresh the figure before exporting but it doesn't help, only mouseover seems to correctly position the bordertext.
Any idea how to fix this?

kind regards
Arnold

arnold

Hi Jan,

can you please comment on my request from one year ago? In your examples you have a 'margin' option, yet it doesn't seem to do anything, at least not in the way I would expect it to.
I'm still looking for a way to add a distance between the axis box and the bordertext. At the moment, there is no gap and the text is in direct contact with the box.

kind regards, arnold.

zilong

Thanks for your good work.

arnold

Hey Jan,
any Chance you can add that padding function? I've looked around the code, it's very well written, but I can't seem to find a way to implement it.

Jeremy

RC

This is super; thanks Jan for bringing to us

arnold

here is what I mean by 'padding'. This is what it looks like right now:
http://img19.imageshack.us/img19/8550/u4mk.gif

This is what I mean by 'padding':
http://img202.imageshack.us/img202/54/t2f.gif

I think this would really help with readability. If one could set a margin of several pixels so the text wasn't touching the axis.

regards
arnold

arnold

thanks Jan. Having the standard matlab syntax available is awesome.

Have you thought about a 'padding'?
The Text Property 'margin' doesn't work since it expands around the text, so maybe you can correct the position by the margin size.

regards
arnold

Thank you Arnold for your comment (and rating). I've solved the background overlap and I added the matlab syntax.
Your other suggestion to add transparency to the text background is impossible, because the text object has no BackgroundAlpha property.

arnold

Another idea:
If you added a "padding" to your positions, this could solve the problem of the background/text overlapping with the axis borderlines. I think it would also look nicer in some cases

arnold

great tool!!!
It would be even better if you could add transparency/alpha to the background-color and bordercolor so one can still see data behind the box.

It would also be a little more intuitive if it used the standard syntax for all the coloring and stuff, i.e.
'BackgroundColor', 'red'

... I guess it'll be hard to memorize the syntax otherwise.

Something else:
When placing Text with a background at 'innertopright' for example, it extends over the axis box line. Would be great if that didn't happen for all Positions.

thanks, this will be quite handy.

Updates

1.5.0.0

Update for HG2

1.4.0.0

Bugfix for R2014b; HandleGraphics2 (zooming,panning etc was not working anymore)

1.3.0.0

Some speed optimizations.
Option added: zoom text when using as Position an [X Y]-position: 'ZoomText','on'

1.2.0.0

Background of the text doesn't overlap the axis anymore.
Added the matlab syntax, as suggested bij arnold

MATLAB Release Compatibility
Created with R2014b
Compatible with any release
Platform Compatibility
Windows macOS Linux