Plot bar chart with log scale on y axis

Hello there,
I want to plot a group bar chart with differences about 10^-4 within the data, positiv and negativ. So the problem is, either I get a bar chart where just the big values are visible and the small ones disappear, or there is some trouble about plotting negative/postitiv data on a log scale.
I tried to add
set(axes1,'YScale','log')
in my code, but it doesn't work as expected, and i dont know which other options i got.

댓글 수: 3

Rik
Rik 2019년 7월 16일
A logarithmic scale doesn't work well when you need to cross the 0. Can you give a small example of your data and the intended output?
It may be the best solution to stick two axes together, one with the positive data and one for the negative.
One of the matrizes:
data1=[-0.000737799000000000 0.0219366000000000 -3.30534000000000 -0.000590114000000000;
-0.00101848000000000 0.0209445000000000 -3.33881000000000 -0.000888108000000000;
-0.000395884000000000 0.0200179000000000 -3.24480000000000 -0.000270600000000000;
-0.00101200000000000 0.0194767000000000 -3.33831000000000 -0.000899477000000000]
An example of my intended output does not exist yet, at least i couldn't find any. But this produces my minimal current output:
fig=figure;
axes1 = axes('Parent',fig);
hold(axes1,'on');
bar1 = bar(data1,'Parent',axes1);
set(bar1(4),'DisplayName','Sphi');
set(bar1(3),'DisplayName','Sz');
set(bar1(2),'DisplayName','Trz');
set(bar1(1),'DisplayName','Sr');
set(fig,'PaperSize',[18 13]);
%set(axes1,'YScale','log') ---> Ignores negative data
Rik
Rik 2019년 7월 16일
Logarithmic scales don't play nice with mixing signs, so it is not entirely clear what you want as an end result. So can you try making an example in something like paint?

댓글을 달려면 로그인하십시오.

답변 (1개)

the cyclist
the cyclist 2019년 7월 16일
편집: the cyclist 2019년 7월 16일

0 개 추천

There are some good thoughts on how to handle this problem in response to this question. In particular, the accepted answer by Matt Tearle seems very useful.
You'll need to adapt to bar chart, but the concept is the same.
Notice that they are doing the log transformation on the X axis, not the Y.

카테고리

도움말 센터File Exchange에서 Annotations에 대해 자세히 알아보기

질문:

2019년 7월 16일

편집:

2019년 7월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by