Redian新闻
>
请问MATLAB中画bar时怎么让x变成对数坐标
avatar
请问MATLAB中画bar时怎么让x变成对数坐标# Computation - 科学计算
g*s
1
bar(x,y)
set(gca,'XSCALE','log')
不行,总出来 Warning:Negative data ignored.
avatar
r*y
2
This is because your x points contain negative values ba, so
log scale ignored them.

【在 g******s 的大作中提到】
: bar(x,y)
: set(gca,'XSCALE','log')
: 不行,总出来 Warning:Negative data ignored.

avatar
g*s
3
no negative values at all in my x points.
my x points are,
x=[1e4 1e5 1e6];

【在 r****y 的大作中提到】
: This is because your x points contain negative values ba, so
: log scale ignored them.

avatar
f*r
4
the reason is a bar has some width
if you look at the linear bar graph, the left most bar
actually has some part in negative region, that's the reason
why you got such an error message.
One not elegant way to get aroud is like this
set the width of bar to be very small:
bar(x,y,0.01)
set(gca,'XScale','log')

【在 g******s 的大作中提到】
: no negative values at all in my x points.
: my x points are,
: x=[1e4 1e5 1e6];

avatar
g*s
5
Thanks a lot. However in this way the width of bars would not be the same.
I use x=[4 5 6] to replace x=[1e4 1e5 1e6]. Afterwards, I change them back
using set(gca,'XTickLabels',['10^4';'10^5';'10^6']). But 上标符号 ^ doesn't
work. Could you anyone tell me how to do with it?
Thanks!

【在 f********r 的大作中提到】
: the reason is a bar has some width
: if you look at the linear bar graph, the left most bar
: actually has some part in negative region, that's the reason
: why you got such an error message.
: One not elegant way to get aroud is like this
: set the width of bar to be very small:
: bar(x,y,0.01)
: set(gca,'XScale','log')

avatar
f*n
7
semilogx(x,y) plots log(x) vs y.

【在 g******s 的大作中提到】
: bar(x,y)
: set(gca,'XSCALE','log')
: 不行,总出来 Warning:Negative data ignored.

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。