0% found this document useful (0 votes)
6 views2 pages

Useful Jupyter

Uploaded by

Samuel Gronwold
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

Useful Jupyter

Uploaded by

Samuel Gronwold
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

1.

MatPlotLib
1.1. plotting things

import numpy as np
from matplotlib import pyplot as plt

x = np.linspace(-1,1,100)
y = x**2

plt.title('Title of Plot')
plt.xlabel('$x$-axis')
plt.ylabel('$y$-axis')

plt.plot(x,y)

We need to setup a plt.axes object with the attribute projection='3d' and call plot_surface on it…

import numpy as np
from matplotlib import pyplot as plt

x,y = np.meshgrid(
np.linspace(0,100,100), #x-range
np.linspace(0,100,100) #y-range
)

z = x**2 + y**2

ax = plt.axes(projection='3d')
ax.plot_surface(x,y,z)

Just initialize the meshgrid with r and θ …


import numpy as np
from matplotlib import pyplot as plt

r,T = np.meshgrid(
np.linspace(0,100,100), #r-range
np.linspace(0,2*np.pi,100) #theta-range
)

x,y = (r*np.cos(T), np.sin(T))

z = r*np.sin(3*T)

ax = plt.axes(projection='3d')
ax.plot_surface(x,y,z)

Last updated 2024-03-30 14:46:49 -0500

You might also like