InspectDR: Basic display Tests


In [ ]:
using InspectDR

#Reset list of displays for demo purposes (in case GtkDisplay is currently active)
function resetdisplays()
    dfltdisp = Base.Multimedia.displays[end]
    if typeof(dfltdisp) <: InspectDR.GtkDisplay
        pop!(Base.Multimedia.displays)
    end
    nothing
end

include("BodePlots.jl") #Defines BodePlots.* utilities.
plot = BodePlots.new()
    fmin = 1e6; fmax = 10e9; G0 = 20
    fzero = Inf; fpole1 = 50e6; fpole2 = 10e9
BodePlots.update(plot, fmin, fmax, G0, fzero, fpole1, fpole2) #Generate some data
println("\"plot\" defined.")

nothing

Test inline SVG plots

NOTE: SVG outputs do not render well in notebooks for some reason...


In [ ]:
#Jupyter typically requests inline graphics as SVG first.
#Allowing MIME"image/svg+xml" renderings therefore produces SVG outputs:
InspectDR.defaults.rendersvg = true

resetdisplays() #Just in case
plot #Implicit call to "optimal" "show(..,::MIME,...)" function

Test inline PNG plots


In [ ]:
#When MIME"image/svg+xml" is disabled, Jupyter eventually requests PNG inline graphics:
InspectDR.defaults.rendersvg = false

resetdisplays() #Just in case
display(plot) #Explicit call to display plot
nothing

Test InspectDR Gtk "Display"


In [ ]:
resetdisplays() #Just in case
pushdisplay(InspectDR.GtkDisplay()) #Make "GtkDisplay" highest priority
display(plot) #This time InspectDR.GtkDisplay() is on top of display stack
nothing

Now test display() with explicit GtkDisplay<:Display object


In [ ]:
resetdisplays()
display(Base.Multimedia.displays) #GtkDisplay should not longer be on display stack
display(InspectDR.GtkDisplay(), plot) #Explicit call to use Gtk "display"
nothing

Save plot to .svg file


In [ ]:
InspectDR.write_svg("plotsave.svg", plot) #High-quality output!

Demo complete!