Suppress exponential formatting in figure ticks

后端 未结 3 1303
余生分开走
余生分开走 2020-11-28 13:10

Tick labels for ticks bigger than about 10\'000, get formatted to 1x10^4 for example. Whereas the exponential part appears above the corresponding axes. This misbehavior has

3条回答
  •  我在风中等你
    2020-11-28 13:40

    One other trick you can try is to scale your data before you plot it, then scale the tick labels to make it appear that it is plotted on a different scale. You can use the function LOG10 to help you automatically compute an appropriate scale factor based on your plotted values. Assuming you have your data in variables x and y, you can try this:

    scale = 10^floor(log10(max(y)));  %# Compute a scaling factor
    plot(x,y./scale);                 %# Plot the scaled data
    yTicks = get(gca,'YTick');        %# Get the current tick values
    set(gca,'YTickLabel',num2str(scale.*yTicks(:),'%.2f'));  %# Change the labels
    

提交回复
热议问题