Skip to content

Plot in generated jupyter notebook not visible #830

@m-kessler

Description

@m-kessler

With recent Jupyter versions the plots in the notebooks generated by the FMPy GUI are not displayed.

This is the notebook I get with fmpy 0.3.26 from the well known CoupledClutches FMU:

import fmpy
from fmpy import *

filename = 'CoupledClutches.fmu'

start_values = {
    # variable                                    start   unit      description
    'CoupledClutches1_T2':     (4.00000000000000000e-01, 's'),    # T2
    'CoupledClutches1_freqHz': (2.00000000000000000e-01, 'Hz'),   # freqHz
    'minsamplestep':           (2.50000000000000000e-02, 's'),    # Minimum time step between samples in binary data file
    'binfilename':                           'DISABLED',          # Name of binary data file
}

output = [
    'outputs[1]',  # J1.w
    'outputs[2]',  # J2.w
    'outputs[3]',  # J3.w
    'outputs[4]',  # J4.w
]

result = simulate_fmu(filename, start_values=start_values, output=output, stop_time=1.5)

plot_result(result)

The plot is not shown when this notebook is executed in Jupyter Lab 4.5.0.

The proposed solution from this answer on stackoverflow works.
After adding the following lines to the start of the notebook, the plot is visible:

import plotly.io as pio
pio.renderers.default = 'iframe'

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions