How to insert an infinity symbol in the X axis of a Matlab Bar chart?

How to add an infinity symbol to the X axis of a Matlab Bar chart?

Naturally, you can add an infinity symbol, i.e. '\infty' for xlabel, as seen from the last line of the inserted code.
But I want to add an infinity sign to an x-axis line that is not in the x-axis label.
How can i do this? For a detailed explanation below is the script:

 data=[1 2 3; 1 3 4; 3 1 2]; bar(data) set(gca,'YLim',[0 3]) set(gca,'YTick',[0:0.5:3]) set(gca, 'YTickLabel',num2str(get(gca,'YTick')','%02.1f%%')) set(gca,'Xtick',1:3,'XTickLabel',{'\infty' ; '20 dB'; '15 dB'}) xlabel('\infty dB') % x-axis label 

Image showing problem

+5
source share
1 answer

What about this solution using format_tick from File Exchange ?:

 data=[1 2 3; 1 3 4; 3 1 2]; bar(data) set(gca,'YLim',[0 3]) set(gca,'YTick',[0:0.5:3]) set(gca, 'YTickLabel',num2str(get(gca,'YTick')','%02.1f%%')) set(gca,'Xtick',1:3) format_ticks(gca, {'$\infty$' ; '20 dB'; '15 dB'}) 

enter image description here

I left xlabel because it interacts with Xtick , but it can probably be easily moved to a lower position.

EDIT: To fix the overlap of Xtick and xlabel , add this to the end of the code:

 xlabh = get(gca,'XLabel'); set(xlabh,'Position',get(xlabh,'Position') - [0 .1 0]) 

enter image description here

+4
source

Source: https://habr.com/ru/post/1206858/


All Articles