I'm trying to create a 3D histogram with bar3 (I don't have the statistic toolbox so I can't use hist3). My data is a 10x10 matrix. Thus I get a 3d hist with x and y axis going from 1 to 10. I would like to change those value to the real value of my variable (0 to 3 and 0 to 100) but I can't use Xlim and Ylim (It also change which are the bar plotted) Anyone has an idea ?
Alex

 채택된 답변

the cyclist
the cyclist 2012년 1월 12일

5 개 추천

Does this do what you want?
bar3(rand(3,4))
set(gca,'XTickLabel',[10 20 30 40])
set(gca,'YTickLabel',[100 200 300])

댓글 수: 1

Roberto Chang
Roberto Chang 2021년 8월 23일
Hello, tons of bikes for you! this was helpful for me.

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

추가 답변 (2개)

Alex
Alex 2012년 1월 12일

0 개 추천

Do the job great ! Thanks for that
Austin
Austin 2013년 6월 17일

0 개 추천

This doesn't really work. I'm trying to plot Z bars against X and Y with more than a few data points. I would like the x and y axis labels to be the real x and y data. Can you help??
Here's and example:
format shortg
xAxis = sort(10*rand(20,1));
sprintf('XMin: %5f xMax: %5f', [min(xAxis) max(xAxis)])
yAxis = sort(30*rand(30,1));
sprintf('yMin: %5f yMax: %5f', [min(yAxis) max(yAxis)])
bar3(rand(20,30));
set(gca,'XTickLabel',xAxis)
set(gca,'YTickLabel',yAxis)

댓글 수: 2

the cyclist
the cyclist 2013년 6월 17일
Not very many people will see your question, which is buried as an "answer" to a 5-month-old question. I suggest you start a brand-new question, and perhaps reference this question with a link.
Rahul
Rahul 2023년 5월 4일
I am guessing you want the contents of the xAxis and yAxis arrays to appear as the labels for the corresponding x and y axis . I simply used a string() method to convert the numeric array to a string and placed that.
set(gca,'XTickLabel',string(xAxis))
set(gca,'YTickLabel',string(yAxis))

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

카테고리

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

질문:

2012년 1월 12일

댓글:

2023년 5월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by