フィルターのクリア

Histogram Y axis to Logarithmic Scale

262 ビュー (過去 30 日間)
Anthony
Anthony 2011 年 8 月 3 日
コメント済み: Eric Rouviere 2019 年 7 月 11 日
I trying to set the Y- axis of a histogram to Logarithimic Scale. I know I can use Y tick but I trying to figure out how I can get the best formulae for this I would be grateful for any help rendered.
hist(data(1:29196,3)) set(gca,'YTick',)

回答 (2 件)

the cyclist
the cyclist 2011 年 8 月 3 日
set(gca,'YScale','log')
  3 件のコメント
Tim Marks
Tim Marks 2017 年 4 月 3 日
I tried the cyclist's command
set(gca,'YScale','log')
on a histogram that I plotted in Matlab 2016b using the "histogram" command, and it worked like a charm. It kept the graph as a histogram, and just changed the y-axis to logarithmic scale, exactly as desired. Maybe it only works properly in recent versions of Matlab, but it did exactly what was needed.
Eric Rouviere
Eric Rouviere 2019 年 7 月 11 日
You are using hist(). Try using histogram().

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


Walter Roberson
Walter Roberson 2011 年 8 月 3 日
The reason your histogram disappears is that the histogram draws each bar down to the value 0, and log(0) is -infinity, so the graphics engine chops off those lines.
Unfortunately changing this behavior is not easy if you require that hist() be used. When you use hist(), the drawn graphic is in the form of a patch. It is possible to set() new YData for the patch, but when you do so other internal aspects of the patch get changed and it ends up a mess.
What you are better off using is:
[n, xout] = hist(data(1:29196,3));
bar(xout, n, 'barwidth', 1, 'basevalue', 1);
set(gca,'YScale','log')
This will cause the bar graph to be drawn only from 1 upward instead of from 0 upward, and log(1) is not a problem to draw.
  1 件のコメント
Jamie
Jamie 2018 年 6 月 22 日
This is great, thanks! I use basevalue of 0.1 so that single occurrences are visible.

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by