How insert squares to figure xlabels and reduce text distance?

18 views (last 30 days)
Hello! My figure contain transparent and less tarnsparent bars and I would like to add a xlabel with such symbols ◼️☐ and put them close together.
I have found already a solution for storing such symbols in the script by putting them into a mat-file but I don't find an all-over solutuon because I can't reduce the spacing between such symbols with tex interpreter and when using latex interpreter I can't generate the squares.
The result should look like:
My Latex text is for example:
text='ROM $\blacksquare${}$\square$';
xlabel(text,'interpreter','latex');
Thanks a lot!
  1 Comment
dpb
dpb on 5 Aug 2019
Whether you can manage to make the packages work with the ML implementation is unknown and wouldn't put high odds on it, but you might look at https://texfaq.org/FAQ-letterspace
AFAIK, the only "simple" way would be to place the text character-by-character with the x,y location with text

Sign in to comment.

Answers (1)

Adam Danz
Adam Danz on 5 Aug 2019
Edited: Adam Danz on 5 Aug 2019
Why not just use legend? That's what it's designed to do (if I understand your question correctly).
%Example
cla()
b1 = bar([1,2],[5,10], 'FaceColor', 'b','FaceAlpha',.5);
hold on
b2 = bar([1,2],[3,8], 'FaceColor', 'r','FaceAlpha',.5);
xlabel('ROM')
legend([b1,b2],{'left','right'},'Orientation', 'horizontal','location', 'southoutside')
If you just want a white box and black box,
cla()
xlabel('ROM ◼️☐') % *
*When you copy/paste this into the command window or a script, 3 boxes will appear instead of two. Delete the middle one.

Categories

Find more on Labels and Annotations in Help Center and File Exchange

Products


Release

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!