对数刻度(x轴)直方图 [英] Log scale (x axis) histogram

查看:343
本文介绍了对数刻度(x轴)直方图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要的是X轴以对数刻度显示的直方图.但是,我仍然希望直方图中的每个条都具有相同的宽度.

what I need is a histogram with X axis displayed on a log scale. However, I still want every bar in a histogram to be of the same width.

无论如何,我想出了(或上面)显示栏,这些栏的值较高而较窄(它们在普通刻度上具有相同的宽度,而不是对数刻度).

Whatever, I came up with (or upon) display bars with higher values as narrower ones (they are of the same width on ordinary scale and not on log scale).

这是我现在正在做的事情:

Here is what I am doing now:

edges = 10.^(c_min:0.1:c_max); 
h = histc(data, edges);
bar(edges, h); set(gca, 'Xscale', 'log');

推荐答案

由于您的钢筋应均匀分布,因此可以使用x值1,2,..绘制它们,然后更改轴标签.

Since your bars should be evenly spaced, you can plot them with x-values 1,2,.. and then change the axis labels.

edges = 10.^(c_min:0.1:c_max); 
h = histc(data, edges);

centers = sqrt(edges(1:end-1).*edges(2:end));

bar(h)

%# fix the x-labels, x-axis extents
xlim([0.5,length(centers)+0.5])
set(gca,'xticklabel',num2str(centers(:),'%5.2f'))

这篇关于对数刻度(x轴)直方图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆