본문 바로가기
유용한 지식/Matlab

Matlab Graph Axis Tick | Plot Advanced Edit1

by 그래도_明 2020. 9. 24.

Matlab Graph Axis Tick | Plot Advanced Edit1

When you draw a graph, the x-axis value or y-axis value is sometimes expressed in a way that you don't like.

For example, suppose you have the following graph.

<Before Changing Axis Ticks>

The x-axis data is marked 'x10^4.' It is not easy to understand them at a glance.
Similarly, the y-axis is also marked 'x10^-3' and is not satisfactory.

 

Therefore, we want to attach k to the x-axis scale value and change the unit to mNm for the y-axis itself to express neatly.

The methods are as follows. Simply paste the code below after the plot function.

xticks([0 10000 20000 30000 40000 50000 60000])
xticklabels({'0','10k','20k','30k','40k','50k','60k'})

yticks([0 0.002 0.004 0.006 0.008])
yticklabels({'0','2','4','6','8'})

~ticks and ~ticklabels are sets, and you can enter the desired values corresponding to each tick value.
The results are as follows:

<After Changing Axis Ticks>

For your information, if you put '\pi' in ~ticklabels, you can make π, so please use it wisely.

 

----

xticks([0 10000 20000 30000 40000 50000 60000]) 
xticklabels({'0','10k','20k','30k','40k','50k','60k'}) 

yticks([0 0.002 0.004 0.006 0.008]) 
yticklabels({'0','2','4','6','8'})

----

반응형

댓글