OMPython icon indicating copy to clipboard operation
OMPython copied to clipboard

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

Open martinscripts opened this issue 6 months ago • 0 comments

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

martinscripts avatar Aug 14 '24 09:08 martinscripts