Bar Chart Log Axis

193 ビュー (過去 30 日間)
Jason
Jason 2017 年 2 月 16 日
編集済み: dpb 2017 年 2 月 22 日
I have data that I want to create a barchart from. I require the x-axis to be log10.
[counts,xb]=hist(data(:,3),nbins); %IMHIST ONLY HANDLES 8 & 16 BIT IMAGES, NOT 12BIT
bar(log10(xb),counts,'r','EdgeColor','r');
grid on;
hold on
xlim([min(log10(xb)) max(log10(xb))])
I have read that I need to do:
set(gca,'Xtick',0:4); %// adjust manually; values in log scale
set(gca,'Xticklabel',10.^get(gca,'Xtick')); %// use labels with linear values
My data is typically 4000-6000
the histogram with log10 x axis looks like the same, and the ticks are not showing?
  8 件のコメント
Jason
Jason 2017 年 2 月 16 日
Thankyou dpb. I see now that my spread isnt big enough to see as you suggested. I take back my comment that it doesnt work. Thanks again
dpb
dpb 2017 年 2 月 16 日
編集済み: dpb 2017 年 2 月 22 日
For confirmation
>> x=(5000:8000); lx=log10(x);
>> [(lx-lx(1))./(lx(end)-lx(1));(x-x(1))./(x(end)-x(1))]
ans =
0 0.3879 0.7159 1.0000
0 0.3333 0.6667 1.0000
>>
pretty same ratios; if don't study carefully wouldn't ever tell the difference...
I moved comment to Answer; please ACCEPT to close the subject if nothing else.

サインインしてコメントする。

採用された回答

dpb
dpb 2017 年 2 月 16 日
If you mean to still bin on linear range want to display x on a log scale, just use
hBar=bar(xb,counts,'r','EdgeColor','r');
set(gca,'XScale','log')
then you can fixup range as want to make it look pretty if the autoscaling doesn't suit.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeVector Fields についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by