getting double legend for one bar plot while running histc!!

I would like to plot histogram with x-axis in log scale.
where my dataset is 1.0e+04 * [4.4463 0.0109 0.0034 0.1224 0.0120];
binranges = logspace(-3,4,8); %1e-3:1e2:1e4;
[bincounts] = histc(data,binranges); % post>pre cir
h1 = bar(binranges,bincounts,'histc','FaceColor',[1 0 0]);
set(h1,'FaceColor','r','EdgeColor','r');
set(gca,'XMinorTick','on','YMinorTick','on','XScale','log');
legend('show')
for this i used above command to my dataset. I want to find the dataset that falls in the range
1 : 5,
6 : 10,
11 : 50
51 :100
101: 500
501:1000
1001:5000
5001:1e4 .... Moreover
For legend. It is taking two legends at a time for one plot!!
I do not understand where aother legend comes from!

댓글 수: 1

madhan ravi
madhan ravi 2019년 1월 2일
편집: madhan ravi 2019년 1월 2일
There is no legends in your code.Show us your legend call.

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

답변 (2개)

KALYAN ACHARJYA
KALYAN ACHARJYA 2019년 1월 2일
편집: KALYAN ACHARJYA 2019년 1월 2일
data=[4.4463 0.0109 0.0034 0.1224 0.0120];
binranges = logspace(-3,4,8); %1e-3:1e2:1e4;
[bincounts] = histc(data,binranges); % post>pre cir
h1 = bar(binranges,bincounts,'histc','FaceColor',[1 0 0]);
set(h1,'FaceColor','r','EdgeColor','r');
set(gca,'XMinorTick','on','YMinorTick','on','XScale','log');
Where you have seen two legands?

댓글 수: 3

Please note on binranges and bincounts
h1=bar(binranges,bincounts,'histc','FaceColor',[1 0 0]);
i edited my question.
KALYAN ACHARJYA
KALYAN ACHARJYA 2019년 1월 2일
편집: KALYAN ACHARJYA 2019년 1월 2일
Check @madhan ravi answer, he already answer the question.
Still if you have problem, let me know here.

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

madhan ravi
madhan ravi 2019년 1월 2일
편집: madhan ravi 2019년 1월 2일
Try this:
data=[1.0e+04 * [4.4463 0.0109 0.0034 0.1224 0.0120];
binranges = logspace(-3,4,8); %1e-3:1e2:1e4;
[bincounts] = histc(data,binranges); % post>pre cir
h1 = bar(binranges,bincounts,'histc','FaceColor',[1 0 0]);
set(h1,'FaceColor','r','EdgeColor','r');
set(gca,'XMinorTick','on','YMinorTick','on','XScale','log');
legend('show','Data') % just change your line to this in your code
% ^^^^-----the name of your legend
Gives:

댓글 수: 3

I have attached data, can anyone help me getting red, blue and green legends only?
[bincounts] = histc((I(:,1)),binranges);
h1 = bar(binranges,bincounts,'histc','FaceColor',[1 0 0]);
set(h1,'FaceColor','r','EdgeColor','r');
hold on;
[bincounts] = histc(1./(D(:,1)),binranges);
h2 = bar(binranges,bincounts,'histc');
set(h2,'FaceColor','g','EdgeColor','g');
hold on;
[bincounts] = histc((NO(:,1)),binranges);
h3 = bar(binranges,bincounts,'histc');
set(h3,'FaceColor','b','EdgeColor','b');
legend('show');
set(gca,'XMinorTick','on','YMinorTick','on','XScale','log');
The above code shows 6 legends for 3 dataset.
Can anyone give me only colors and no * mark.
Also I would like to turn off astrisk (*) mark.
Continued in a new thread.

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

카테고리

질문:

2019년 1월 2일

댓글:

Rik
2019년 1월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by