Tips and tricks¶
In [1]:
Copied!
import matplotlib.pyplot as plt
from example_models import get_linear_chain_2v
from modelbase2 import Simulator, plot
from modelbase2.types import unwrap
import matplotlib.pyplot as plt
from example_models import get_linear_chain_2v
from modelbase2 import Simulator, plot
from modelbase2.types import unwrap
Renaming plots arguments¶
The easiest way to rename plot arguments, e.g. for LaTeX
display, is to work on the pandas.DataFrame
directly.
This conveniently offers a rename
method, to which you can supply a dictionary of desired names.
In [2]:
Copied!
concs = unwrap(Simulator(get_linear_chain_2v()).simulate(5).get_result()).variables
fig, ax = plot.lines(
concs.rename(
columns={
"x": r"$x_{1}$",
"y": r"$x_{2}$",
}
)
)
ax.set(xlabel="time / a.u.", ylabel="concentration / a.u.")
plt.show()
concs = unwrap(Simulator(get_linear_chain_2v()).simulate(5).get_result()).variables
fig, ax = plot.lines(
concs.rename(
columns={
"x": r"$x_{1}$",
"y": r"$x_{2}$",
}
)
)
ax.set(xlabel="time / a.u.", ylabel="concentration / a.u.")
plt.show()