标签坐标选取

ntick=10;

a=1000;
b=1890;

gstep=(b-a)/ntick;
step=10^floor(log10(gstep));

if( 5*step<gstep )
    step=step*5;
elseif (2*step<gstep)
    step=step*2;
end

ntick=int32( floor( b/step ) -ceil(a/step) );

min1=ceil(a/step)*step;
max1=floor(b/step)*step;

xx=[min1:step:max1]
size(xx)

  这个是选择一个小坐标,如果要选择大坐标可以将  ntick=int32( floor( b/step ) -ceil(a/step) ); 句中的floor 和ceil 换位置。

前者适应于图像一定标注里面的坐标,后者适应于图像一定画在一个更大的画布上的情况。

 

内容参考自C++ GUI Qt4 编程(第二版)

posted on 2015-12-28 22:16  reedlau  阅读(224)  评论(0编辑  收藏  举报

导航