-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLogScale.nim
29 lines (26 loc) · 882 Bytes
/
LogScale.nim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import std/[math]
import imgui
import implot
#--------------------
# demo_Axes_LogScale()
#--------------------
proc demo_Axes_LogScale*() =
var
xs {.global.} : array[1001,cdouble]
ys1{.global.} : array[1001,cdouble]
ys2{.global.} : array[1001,cdouble]
ys3{.global.} : array[1001,cdouble]
once:
for i in 0..<1001:
xs[i] = i.float32 * 0.1f
ys1[i] = sin(xs[i]) + 1
ys2[i] = log(xs[i],10)
ys3[i] = pow(10.0, xs[i])
if ipBeginPlot("Log Plot", ImVec2(x: -1,y: 0)):
defer: ipEndPlot()
ipSetupAxisScale(ImAxis.X1, ImPlotScale.Log10)
ipSetupAxesLimits(0.1, 100, 0, 10)
ipPlotLine("f(x) = x", xs.ptz, xs.ptz, 1001)
ipPlotLine("f(x) = sin(x)+1", xs.ptz, ys1.ptz, 1001)
ipPlotLine("f(x) = log(x)", xs.ptz, ys2.ptz, 1001)
ipPlotLine("f(x) = 10^x", xs.ptz, ys3.ptz, 21)