-
Notifications
You must be signed in to change notification settings - Fork 9
/
demo1.jl
78 lines (64 loc) · 2.48 KB
/
demo1.jl
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#Demo 1: Simple sine wave plot
#-------------------------------------------------------------------------------
using InspectDR
using Colors
import NumericIO: UEXPONENT_SI
#==Input
===============================================================================#
#Constants
#-------------------------------------------------------------------------------
black = RGB24(0, 0, 0)
white = RGB24(1, 1, 1)
red = RGB24(1, 0, 0)
green = RGB24(0, 1, 0)
blue = RGB24(0, 0, 1)
#Input data
#-------------------------------------------------------------------------------
tcycle = 1e-9
npts = 2000 #Relatively large dataset
ncycles = 4
tmax = tcycle*ncycles
Δ = tmax/(npts-1)
t = collect(0:Δ:tmax)
y = sin.(t*(ncycles*2pi/tmax))
t[end] = t[1] #x-values are no longer ordered
#Lower resolution t-vector:
t_lres = collect(0:(tmax/10):tmax)
#==Generate plot
===============================================================================#
plot = InspectDR.transientplot(:lin, title="Sample Plot (π𝜋α𝛼β𝛽γ𝛾Ω𝛺℧ϕ𝜑𝜙ω𝜔f𝑓ϵ𝜀λ𝜆,⇒x∊ℝ)")
InspectDR.overwritefont!(plot.layout, fontname="monospace", fontscale=1.5)
#TODO: change how layout[] works. Not obvious that you can't just set .bold property of a font
tf = plot.layout[:font_title]; tf.bold = false #Must read first
plot.layout[:font_title] = tf #Then assign to flag property changed
plot.layout[:enable_legend] = true
plot.layout[:halloc_legend] = 150
plot.layout[:enable_timestamp] = true
plot.layout[:format_xtick] = InspectDR.TickLabelStyle(UEXPONENT_SI) #Use SI notation on x-axis
graph = plot.strips[1]
graph.grid = InspectDR.GridRect(vmajor=true, vminor=true, hmajor=true)
style = :dashdot #solid/dashdot/...
wfrm = add(plot, t, y .+1, id="sin(2πt)+1")
wfrm.line = line(color=blue, width=1, style=style)
wfrm = add(plot, t, y .-1, id="sin(2πt)-1")
wfrm.line = line(color=red, width=5, style=style)
wfrm = add(plot, t_lres, -2 .+4*(t_lres./tmax), id="-2+4t/tmax")
wfrm.line = line(color=blue, width=3, style=:dash)
wfrm.glyph = glyph(shape=:*, size=10)
a = plot.annotation
a.xlabel = "Time (s)"
a.ylabels = ["Signal Voltage (V)"]
let wfrm #HIDEWARN_0.7
#Show if uses f1 acceleration:
for wfrm in plot.data
id = wfrm.id
f1accel = isa(wfrm.ds, InspectDR.IDataset{true})
@show id, f1accel
end
end
gplot = display(InspectDR.GtkDisplay(), plot)
InspectDR.write_png("export_plot.png", plot)
InspectDR.write_svg("export_plot.svg", plot)
InspectDR.write_eps("export_plot.eps", plot)
InspectDR.write_pdf("export_plot.pdf", plot)
:DONE