필터 지우기
필터 지우기

Add only top axis in plot

조회 수: 6 (최근 30일)
youngz
youngz 2018년 9월 17일
답변: Vishal Chaudhary 2018년 9월 24일
Hi,
I have a barh plot. Suppose it is generated by:
c = categorical({'apples','pears','oranges'});
prices = [1.23 0.99 2.3];
barh(c,prices)
and the resultant plot is
Thus, I want to add the bottom axis on the top. I have tried the following code, but without obtains the desired result:
ax = gca; % current axes
ax_pos = ax.Position; % position of first axes
ax2 = axes('Position',ax_pos,...
'XAxisLocation','top',...
'Color','none');
And the result is:
As you can see, in the left bar appears the numerical indexes. Do you have a solution?

답변 (1개)

Vishal Chaudhary
Vishal Chaudhary 2018년 9월 24일
The axes function creates a new axes rather than changing location of previous one.
To change the location of x axes only, you can try:
ax = gca; % current axes
ax.XAxisLocation='top'; % change location for the created axes
You can read more about changing axes properties through: https://www.mathworks.com/help/matlab/ref/matlab.graphics.axis.axes-properties.html

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by