kdavies4 / ModelicaRes

Set up, analyze, and plot Modelica simulations in Python
http://kdavies4.github.io/ModelicaRes/
Other
51 stars 20 forks source link

Using subplot and other matplotlib functionality #31

Closed Mathadon closed 9 years ago

Mathadon commented 9 years ago

Hi,

I started working with ModelicaRes today. I was exploring the options but I'm stuck at the following.

I'd like to use the subplot command from matplotlib. Intuitively I tried:

sim = SimRes(arguments)
sim.add_subplot(2,1,1)    //from http://matplotlib.org/examples/animation/subplots.html
sim.plot(title="Title", ynames1=  ... etc)

but this does not seem to work. I can't seem to find an example in the documentation either. How can I approach this?

Thank you!

kdavies4 commented 9 years ago

Filip, I got swamped and missed this. I'm sorry for the delay. Try something like this:

from matplotlib import pyplot as plt
from modelicares import SimRes

sim = SimRes('ChuaCircuit.mat')
sim.plot('L.v', ax1=plt.subplot(121))
sim.plot('L.i', ax1=plt.subplot(122))
plt.show()

figure_1

The relevant documentation is here, although I admit that solution isn't clear.

kdavies4 commented 9 years ago

If that works for you, feel free to close this issue.

Mathadon commented 9 years ago

thanks @kdavies4 I'm sure it works but I started using 'regular' matPlotLib plots in the meantime :)