.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_auto_examples/plot_bode.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr__auto_examples_plot_bode.py: Plot Bode ===================================== :func:`sysplot.plot_bode` produces a two-panel Bode diagram from magnitude, phase, and frequency arrays. Phase is automatically unwrapped and labelled in multiples of π. The ``mag_to_dB`` flag switches between dB and linear magnitude, and ``minor_ticks`` adds minor decade marks to the log frequency axis. .. GENERATED FROM PYTHON SOURCE LINES 10-35 .. rst-class:: sphx-glr-horizontal * .. image-sg:: /_auto_examples/images/sphx_glr_plot_bode_001.png :alt: mag_to_dB=True, minor_ticks=True :srcset: /_auto_examples/images/sphx_glr_plot_bode_001.png :class: sphx-glr-multi-img * .. image-sg:: /_auto_examples/images/sphx_glr_plot_bode_002.png :alt: mag_to_dB=False, minor_ticks=False :srcset: /_auto_examples/images/sphx_glr_plot_bode_002.png :class: sphx-glr-multi-img .. code-block:: Python import numpy as np import matplotlib.pyplot as plt import control as ctrl import sysplot as ssp ssp.apply_config() system = ctrl.tf([6.25], [1, 3, 6.25]) omega = np.logspace(-2, 2, 1000) mag, phase, _ = ctrl.frequency_response(system, omega) # dB magnitude with minor ticks (default behaviour) fig, axes = plt.subplots(1, 2, figsize=ssp.get_figsize(ncols=2), sharex=True) ssp.plot_bode(mag, phase, omega, axes=axes) axes[0].set(title="mag_to_dB=True, minor_ticks=True", ylabel="Magnitude [dB]") axes[1].set(ylabel="Phase [rad]", xlabel="Frequency [rad/s]") plt.show() # Linear magnitude without minor ticks fig, axes = plt.subplots(1, 2, figsize=ssp.get_figsize(ncols=2), sharex=True) ssp.plot_bode(mag, phase, omega, axes=axes, mag_to_dB=False, minor_ticks=False) axes[0].set(title="mag_to_dB=False, minor_ticks=False", ylabel="Magnitude [linear]") axes[1].set(ylabel="Phase [rad]", xlabel="Frequency [rad/s]") plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.194 seconds) .. _sphx_glr_download__auto_examples_plot_bode.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_bode.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_bode.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_bode.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_