New imports... switched order so that PyCharm will pick up with Python 3 import first
This commit is contained in:
parent
aeafdfeb19
commit
4548b1dd9b
84 changed files with 1071 additions and 265 deletions
28
ProgrammingClassExamples/9c Plot (axes pi format).py
Normal file
28
ProgrammingClassExamples/9c Plot (axes pi format).py
Normal file
|
@ -0,0 +1,28 @@
|
|||
#Plt using matplylib, plotly and numpy
|
||||
#Tony Crewe
|
||||
#Sep 2017 updated Sep 2018
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
import matplotlib.ticker as ticker
|
||||
|
||||
fig=plt.figure()
|
||||
ax = fig.add_subplot(111)
|
||||
x = np.linspace(-np.pi*2, np.pi*2, 100)
|
||||
y= np.sin(x)
|
||||
ax.plot(x/np.pi,y)
|
||||
|
||||
ax.set_title('sin(x)')
|
||||
ax.spines['left'].set_position('zero')
|
||||
ax.spines['right'].set_color('none')
|
||||
ax.spines['bottom'].set_position('zero')
|
||||
ax.spines['top'].set_color('none')
|
||||
|
||||
#Format axes - nicer eh!
|
||||
ax.xaxis.set_major_formatter(ticker.FormatStrFormatter('%g $\pi$'))
|
||||
|
||||
plt.show()
|
||||
|
||||
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue