示例#1
0
#!/usr/bin/python
"""Example of util.shift_scale_y()
"""

# pylint: disable=I0011, C0103, E1101, R0801

import numpy as np

from modelicares import util
from modelicares.texunit import number_label

# Generate some random data.
x = range(100)
y = np.cumsum(np.random.random(100) - 0.5)
y -= y.min()
y *= 1e-3
y += 1e3  # Small magnitude and large offset
ylabel = number_label('Velocity', 'mm/s')

# Plot the data.
ax = util.setup_subplots(2, 2, label='examples/shift_scale_y')[0]
for a in ax:
    a.plot(x, y)
    a.set_ylabel(ylabel)

# Shift and scale the axes.
ax[0].set_title('Original plot')
ax[1].set_title('After applying offset and factor')
util.shift_scale_y(ax[1])
#!/usr/bin/python
"""Example of util.shift_scale_x()
"""

# pylint: disable=I0011, C0103, E1101

import numpy as np

from modelicares import util
from modelicares.texunit import number_label

# Generate some random data.
x = np.linspace(55478, 55486, 100)  # Small range and large offset
xlabel = number_label('Time', 's')
y = np.cumsum(np.random.random(100) - 0.5)

# Plot the data.
ax = util.setup_subplots(2, 2)[0]
for a in ax:
    a.plot(x, y)
    a.set_xlabel(xlabel)

# Shift and scale the axes.
ax[0].set_title('Original plot')
ax[1].set_title('After applying offset and factor')
util.shift_scale_x(ax[1])
#!/usr/bin/python
"""Example of util.setup_subplots()
"""

# pylint: disable=I0011, C0103

from modelicares import util

util.setup_subplots(4, 2, label='examples/setup_subplots')