Skip to content

Commit bdd75ac

Browse files
authored
Merge pull request #28 from JuliaComputing/vk/graph
Comment `Plots` in the tests and add explanation of ngspice-`plot`
2 parents f590d19 + 5dac37d commit bdd75ac

File tree

2 files changed

+12
-26
lines changed

2 files changed

+12
-26
lines changed

src/API/graphs.jl

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,15 @@ struct NgSpiceGraphs end
66

77
const graph = NgSpiceGraphs()
88

9-
@recipe function ng(::NgSpiceGraphs, fort, veclist, title, xlims=nothing)
10-
ft = getrealvec(fort)
11-
legend := true
12-
grid := true
13-
title := "$title"
14-
background_color --> Colors.RGB(0.0, 0.0, 0.0)
15-
xguide := fort
16-
guide := String.(veclist)
17-
color_palette --> :default
18-
seriestype := :path
19-
overwrite_figure := false
20-
vec = getrealvec.(veclist)
21-
#isa(xlims, Nothing) || xlims := xlims
22-
ft, vec
23-
end
24-
9+
# `fort` is frequency or time vector. It is the `X` axis and should always be real.
2510
@recipe function ng(::NgSpiceGraphs, vectype, fort, veclist, title, xlims=nothing)
2611
ft = getrealvec(fort)
27-
legend := true
12+
label := permutedims(veclist)
2813
grid := true
2914
title := "$title"
3015
background_color --> Colors.RGB(0.0, 0.0, 0.0)
3116
xguide := fort
32-
guide := String.(veclist)
17+
guide := length(veclist) > 1 ? "signals" : "signal"
3318
color_palette --> :default
3419
seriestype := :path
3520
overwrite_figure := false

tutorials/mosfet.jl

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using NgSpice
2-
using Plots
2+
# using Plots
33
n = NgSpice
44

55
netpath = joinpath(@__DIR__, "..", "inputs", "mosfet.cir") |> normpath
@@ -11,10 +11,11 @@ n.display() # Returns a dataframe of current vectors
1111
n.listallvecs() # Lists vectors of both active and inactive plots
1212
n.curplot() # Current active plot
1313
n.listcurvecs() # Vectors in current active plot
14-
# Vector type can be specified by sending it as a parameter
15-
# plot(n.graph, n.getimagvec, "time", ["emit", "vcc"], "Title of the plot")
16-
sweep = n.getvec("time")[end] # Returns vector info of `time` vector
17-
emit = n.getvec("emit")[end] # Returns vector info of `emit` vector
18-
vcc = n.getvec("vcc")[end] # Returns vector info of `vcc` vector
19-
plot(sweep, [emit vcc], label=["emit" "vcc"], title="Title of the plot")
20-
n.exit() # Runs "unset askquit" of Ngspice
14+
15+
# For plotting the signals, pass `n.graph` an object of `NgSpiceGraphs` type.
16+
# And then, specify the get-vector method.
17+
# Pass "time" or "frequency"
18+
# List of signals to plot
19+
# Finally, the title of the plot
20+
# plot(n.graph, n.getimagvec, "time", ["emit", "vcc"], "Simple MOSFET")
21+
# plot(n.graph, n.getrealvec, "time", ["emit", "vcc"], "Simple MOSFET")

0 commit comments

Comments
 (0)