Ask Your Question

PaulF's profile - activity

2022-06-16 11:27:32 +0100 received badge  Famous Question (source)
2021-04-08 15:21:50 +0100 received badge  Notable Question (source)
2020-11-01 12:51:38 +0100 received badge  Popular Question (source)
2019-05-20 20:47:55 +0100 commented question Options, e.g. title, thickness, etc for plot3d and parametric_plot3d?

Thanks. I resolved the thickness issue. As for the surface, here's what I have so far, which works:

import matplotlib.pyplot as plt

import numpy as np

fig = plt.figure()

ax = fig.gca(projection='3d')

X = np.arange(-1, 1, 0.25)

Y = np.arange(-1, 1, 0.25)

X, Y = np.meshgrid(X, Y)

Z=X**2+Y**2

surf = ax.plot_surface(X, Y, Z,)

plt.title('$f(x,y)=x^2+y^2$', loc='right', horizontalalignment='center', verticalalignment='top')

plt.show()

Three questions:

  1. Is there a more efficient way to create surface above?

  2. How might I superimpose a cross-section on the surface?

  3. Is it possible to add a command/routine to permit rotating the surface with a mouse?

Thanks.

2019-05-20 19:13:29 +0100 received badge  Nice Question (source)
2019-05-19 23:28:10 +0100 received badge  Student (source)
2019-05-18 11:55:09 +0100 asked a question Options, e.g. title, thickness, etc for plot3d and parametric_plot3d?

I'm switching from Mathematica to Sage for teaching purposes and am having some difficulty with plot options. Here's an example, in which I create the function f(x,y)=x^2+y^2 and plot the function along with the cross-section curve f(.2,y).

 x,y = var('x,y')
f(x,y) = x^2 + y^2

Surface=plot3d(f(x,y),(x,-1,1),(y,-1,1), frame=True,color='green', opacity=0.1,title='A plot of $f(x,y)$')
x0=.2
Cross_Section=parametric_plot3d((x0,y,f(x0,y)), (y,-1,1), color='red', thickness=5)
Cross_Section+Surface

Questions:

  1. The title does not appear. How can I correct that?
  2. Changing the "thickness" option doesn't appear to have any effect on the cross-section curve.

For 2-dim graphs, I don't seem to encounter problems. To plot a contour diagram for the above function, I entered the following, which worked fine:

C=contour_plot(f,(-1,1),(-1,1),fill=False, cmap='hsv', labels=True,gridlines=True,title='Contour Plot of $f(x,y)=x^2+y^2$')
C.axes_labels(['$x$','$y$'])
C.axes_labels_size(2.5)   
C.fontsize(6)    
C
2019-05-18 11:55:09 +0100 asked a question Adding title, modifying axes labels, etc. for plot3d?

I'm switching from Mathematica to Sage for teaching purposes and am having some difficulty with plot options. Here's an example, in which I create the function f(x,y)=x^2+y^2 and plot the function along with the cross-section curve f(.2,y).

 x,y = var('x,y')
f(x,y) = x^2 + y^2

Surface=plot3d(f(x,y),(x,-1,1),(y,-1,1), frame=True,color='green', opacity=0.1,title='A plot of $f(x,y)$')
x0=.2
Cross_Section=parametric_plot3d((x0,y,f(x0,y)), (y,-1,1), color='red', thickness=5)
Cross_Section+Surface

Questions:

  1. The title does not appear. How can I correct that?
  2. Changing the "thickness" option doesn't appear to have any effect on the cross-section curve.

For 2-dim graphs, I don't seem to encounter problems. To plot a contour diagram for the above function, I entered the following, which worked fine:

C=contour_plot(f,(-1,1),(-1,1),fill=False, cmap='hsv', labels=True,gridlines=True,title='Contour Plot of $f(x,y)=x^2+y^2$')
C.axes_labels(['$x$','$y$'])
C.axes_labels_size(2.5)   
C.fontsize(6)    
C