Adaptive gridlines

后端 未结 3 643
旧时难觅i
旧时难觅i 2020-12-18 01:36

I want to use gridlines to create an effect of millimeter graphing paper on a 2d graph, to show how multi-variable function depends on 1 variable. The scales of different va

3条回答
  •  北海茫月
    2020-12-18 02:21

    I think FindDivisions[ ] is what you're after:

    FindDivisions[{xmin,xmax},n] finds a list of about n "nice" numbers that divide the interval around xmin to xmax into equally spaced parts.

    getTicks[x_, y_] := Flatten@FindDivisions[#, {10}] & /@ FromTo[x, y]
    getGrid  [x_,y_] := FindDivisions[{x,y},{10,5}]/.
                              {r__,{s__}}:>Join@@{s,{#,{Gray,Thick}}&/@r} 
    

    enter image description here

提交回复
热议问题