刻度軸 規範值演算法

2021-07-05 21:35:56 字數 895 閱讀 3031

//cormax 資料最大值

//cormin 資料最小值

//cornumber 刻度個數

public void standard(ref double cormax, ref double cormin, int cornumber)

else

//將步長修正到(o,1)問

tmpstep = corstep / temp;

//選取規範步長

if (tmpstep >= 0 && tmpstep <= 0.1)

else if (tmpstep >= 0.100001 && tmpstep <= 0.2)

else if (tmpstep >= 0.200001 && tmpstep <= 0.25)

else if (tmpstep >= 0.25001 && tmpstep <= 0.5)

else

//規範步長按數量級還原

tmpstep = tmpstep * temp;

//修正起點值

if ((int)(cormin / tmpstep) != (cormin / tmpstep))

if ((int)(cormax / tmpstep) != (cormax / tmpstep))

//看最後修正是否必要,包括:刻度數、起點值、終點值

tmpnumber = convert.toint32((cormax - cormin) / tmpstep);

if (tmpnumber < cornumber)

else

cormin = cormin - tmpstep * (int)(extranumber / 2);

if (cormin < 0)

}cornumber = tmpnumber;}}

matplotlib 修改座標軸刻度值,刻度個數

主要是設定座標軸刻度值的數值特徵 例如為2 或 5 或 10 的倍數 以及 刻度值的文字格式 如 浮點型 或者 整型 這個是在工作中處理資料遇到的,系統自動預設的座標軸上的資料是浮點數,而我要求是整數 目前已解決 關鍵 from matplotlib.ticker import multiplelo...

python座標軸刻度設定對數 用對數刻度設定刻度

我將新增一些圖並顯示如何刪除較小的刻度線 op from matplotlib import pyplot as plt fig1,ax1 plt.subplots ax1.plot 10,100,1000 1,2,3 ax1.set xscale log ax1.set xticks 20,300...

座標軸範圍及刻度的自適應演算法

本文參考部落格 由於我是固定了刻度數,美觀的呈現圖表,所以在原博主演算法上進行了修改 var calculaterulermark function arrmark,nummin,nummax,iheight,iactualmarknum var iminmark nummin var imaxma...