How can I add the infinity symbol to X axis of Matlab Bar graph?
Naturally it is possible to insert the infinity symbol i.e. '\infty'
for xlabel, as seen in the last line of the inserted code.
But, I want to add the infinity sign in the x axis bar not in the x axis label.
How can I do that?
For the sake of detailed clarification, the following script is added bellow:
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
How about this solution, using format_tick
function 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'})
I left out the xlabel
because it interfers with the Xtick
, but probably that can be easily moved to 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])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With