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:
- The title does not appear. How can I correct that?
- 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
Hello, @PaulF. It is my understanding that SageMath doesn't use a graphics library for 3D plots; it stores the plots into data structures, and then uses software like Jmol, Tachyon or three.js to render the corresponding 3D scene. Unfortunately, the
title
parameter doesn't seem to be implemented (?).So, as for your first question, I have a coiple of suggestions: 1. You could hack Sage's 3D-plotting subroutines to use a title (that's the beauty of open-source). 2. You could plot directly with Matplotlib, which is part of Sage itself. (Please, let me know if you require help with this, and how soon you need it.)
Regarding your second question, I have tried changing the thickness to 1 (for example), and it worked correctly. Can you confirm the problem again?
Thanks. I resolved the thickness issue. As for the surface, here's what I have so far, which works:
Three questions:
Is there a more efficient way to create surface above?
How might I superimpose a cross-section on the surface?
Is it possible to add a command/routine to permit rotating the surface with a mouse?
Thanks.
Hello, @PaulF. Unfortunately I have failed miserably trying to mix the cross section with your Matplotlib plot. I have tried other alternatives. For example, I tried using the
text3d
command; however, it makes the axes a little larger. Then I tried to rewrite the code that renders Jmol scenes, and I succeeded, but only with static images (PNG, etc.). I failed doing it with dynamic ones, because the base code for 3D plotting is written in Cython, which I don't know very well.I am so sorry I failed with this! I will keep trying to modify my code to work with dynamic images. If I do it, I will send you the code immediately.
Maybe the lack of a title command for 3D plots should be filed as a bug. Can somebody confirm this?