MCPcopy Index your code
hub / github.com/PySimpleGUI/PySimpleGUI / DifferentScales

Function DifferentScales

DemoPrograms/Demo_Matplotlib_Browser.py:614–639  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

612 return fig
613
614def DifferentScales():
615 import numpy as np
616 import matplotlib.pyplot as plt
617
618 # Create some mock data
619 t = np.arange(0.01, 10.0, 0.01)
620 data1 = np.exp(t)
621 data2 = np.sin(2 * np.pi * t)
622
623 fig, ax1 = plt.subplots()
624
625 color = 'tab:red'
626 ax1.set_xlabel('time (s)')
627 ax1.set_ylabel('exp', color=color)
628 ax1.plot(t, data1, color=color)
629 ax1.tick_params(axis='y', labelcolor=color)
630
631 ax2 = ax1.twinx() # instantiate a second axes that shares the same x-axis
632
633 color = 'tab:blue'
634 ax2.set_ylabel('sin', color=color) # we already handled the x-label with ax1
635 ax2.plot(t, data2, color=color)
636 ax2.tick_params(axis='y', labelcolor=color)
637
638 fig.tight_layout() # otherwise the right y-label is slightly clipped
639 return fig
640
641def ExploringNormalizations():
642 import matplotlib.pyplot as plt

Callers

nothing calls this directly

Calls 1

plotMethod · 0.45

Tested by

no test coverage detected