Skip to content

matplotlib.pyplot.savefig() breaks after useing model.linearize() #224

Description

@martinscripts

Description

I can't use pyplot.savefig() from matplotlib.pyplot after linearizing a model with OMPython.

Steps to Reproduce

from OMPython import OMCSessionZMQ
omc = OMCSessionZMQ()
model_path=omc.sendExpression("getInstallationDirectoryPath()") + "/share/doc/omc/testmodels/"
from OMPython import ModelicaSystem
import matplotlib.pyplot as plt

mod1 = ModelicaSystem(model_path + "BouncingBall.mo","BouncingBall")

plt.plot([1,2,3])
plt.savefig('test_before.png')
plt.show()

mod1.linearize()

plt.plot([1,2,3])
plt.savefig('test_after.png')
plt.show()

The test_before.png will be saved, the test_after.png will not.
If you remove mod1.linearize(), both will be saved.

Expected Behavior

savefig should work in both cases.

Screenshots

Version and OS

  • Python Version 3.10.11
  • OMPython Version 3.6.0
  • OpenModelica Version 1.18
  • OS: win10

Activity

  1. syntron commented on Aug 18, 2025

    @syntron
    Contributor

    I just tested it - this is solved by PR #320 -no execution of the created Python file (but using the ast module). Thus, there is no interaction with any other Python code!

  2. martinscripts commented on Aug 19, 2025

    @martinscripts
    Author

    Perfect, thank you.
    I checked, an I get this error now #196
    But I'll close this issue now.

  3. added this to the 4.0.0 milestone on Aug 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions