phymhan/matlab-axis-label-alignment

버전 1.7.0.0 (144 KB) 작성자: Ligong Han
Align axis labels nicely in parallel with axes in MATLAB (3-D) plots.
다운로드 수: 7.1K
업데이트 날짜: 2017/12/23

편집자 메모: This file was selected as MATLAB Central Pick of the Week

This is a simple MATLAB function for axis label alignment. It still works when Projection mode is Perspective or when DataAspectRatio is not [1 1 1].
## Functions
- `align_axislabel`: it rotates $x$, $y$ and $z$ labels to the direction of their corresponding axes and moves the labels to a proper distance from the axes;
- `align_axislabel_log`: supports log-scale in $z$ axis;
- `axislabel_rotation`: it performs rotation only;
- `axislabel_rotation_angle`: it computes the angles of $x$, $y$ and $z$ labels to be rotated properly (without performing the actual rotation);
- `axislabel_translation`: it moves axis labels to a proper distance from the axes;
- `axislabel_translation_slider`: a GUI slider for setting parameters `AXISALIGN_TRANS_A` and `AXISALIGN_TRANS_B`.
## Common usage
Label alignment plus GUI slider:
```
z = peaks;
figure('color', [1 1 1])
surf(z);
set(gca, 'dataaspectratio', [1 1 0.5], 'projection', 'perspective', 'box', 'on')
xlabel('This is an x label', 'fontsize', 16, 'fontweight', 'bold', 'color', [1 0 0])
ylabel('This is a y label', 'fontsize', 16, 'fontweight', 'bold', 'color', [0 0 0])
zlabel('This is a z label', 'fontsize', 16, 'fontweight', 'bold', 'color', [0 0 1])

% Add the following after you plot your figures
h = rotate3d;
set(h, 'ActionPreCallback', 'set(gcf,''windowbuttonmotionfcn'',@align_axislabel)')
set(h, 'ActionPostCallback', 'set(gcf,''windowbuttonmotionfcn'','''')')
set(gcf, 'ResizeFcn', @align_axislabel)
align_axislabel([], gca)
axislabel_translation_slider;

```

See `demo.m` for more information.

인용 양식

Ligong Han (2024). phymhan/matlab-axis-label-alignment (https://github.com/phymhan/matlab-axis-label-alignment), GitHub. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2016a
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Axis Labels에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

GitHub 디폴트 브랜치를 사용하는 버전은 다운로드할 수 없음

버전 게시됨 릴리스 정보
1.7.0.0

- updates examples

1.6.0.0

- Adds GUI slider for parameter setting (controlling translation behaviour)

1.5.0.0

- Adds check for class of 'ax' in align_axislabel.m
- Adds a new example where axis labels are updated/aligned as you rotate the plot simultaneously
- Adds example for subplots
- Changes align_axislabel.m back to align_axislabels.m, sorry for the confusion
- Fixes typos in examples
- Log scale on z axis

1.4.0.0

- Revised for R2014b
- Adds a trans_mode option

1.3.0.0

- Modified the method to move labels to avoid potential overlap;
- Modified parameters in axis_translation.

1.2.0.0

- Modified the direction of axis label translation

1.1.0.0

- Added a function for translation
- Updated descriptions

1.0.0.0

이 GitHub 애드온의 문제를 보거나 보고하려면 GitHub 리포지토리로 가십시오.
이 GitHub 애드온의 문제를 보거나 보고하려면 GitHub 리포지토리로 가십시오.