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

Function create_pyplot_scales

DemoPrograms/Demo_Matplotlib_Styles.py:104–152  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

102
103
104def create_pyplot_scales():
105 plt.close('all')
106 # Fixing random state for reproducibility
107 np.random.seed(19680801)
108
109 # make up some data in the interval ]0, 1[
110 y = np.random.normal(loc=0.5, scale=0.4, size=1000)
111 y = y[(y > 0) & (y < 1)]
112 y.sort()
113 x = np.arange(len(y))
114
115 # plot with various axes scales
116 plt.figure(1)
117
118 # linear
119 plt.subplot(221)
120 plt.plot(x, y)
121 plt.yscale('linear')
122 plt.title('linear')
123 plt.grid(True)
124
125 # log
126 plt.subplot(222)
127 plt.plot(x, y)
128 plt.yscale('log')
129 plt.title('log')
130 plt.grid(True)
131
132 # symmetric log
133 plt.subplot(223)
134 plt.plot(x, y - y.mean())
135 plt.yscale('symlog', linthreshy=0.01)
136 plt.title('symlog')
137 plt.grid(True)
138
139 # logit
140 plt.subplot(224)
141 plt.plot(x, y)
142 plt.yscale('logit')
143 plt.title('logit')
144 plt.grid(True)
145 # Format the minor tick labels of the y-axis into empty strings with
146 # `NullFormatter`, to avoid cumbering the axis with too many labels.
147 plt.gca().yaxis.set_minor_formatter(NullFormatter())
148 # Adjust the subplot layout, because the logit one may take more space
149 # than usual, due to y-tick labels like "1 - 10^{-3}"
150 plt.subplots_adjust(top=0.92, bottom=0.08, left=0.10, right=0.95, hspace=0.25,
151 wspace=0.35)
152 return plt.gcf()
153
154
155# ----------------------------- The draw figure helpful function -----------------------------

Callers

nothing calls this directly

Calls 3

normalMethod · 0.80
closeMethod · 0.45
plotMethod · 0.45

Tested by

no test coverage detected