ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 16 May 2019 03:12:51 +0200Discontinuous surface color by z-levelhttps://ask.sagemath.org/question/46541/discontinuous-surface-color-by-z-level/Hi there,
I want to plot a surface $z=f(x,y)$ together with the level curves (side by side). I know how to doi it when $f$ is continuous, or even bounded, but I run in trouble for uglier functions. Here are two examples (in CoCalC : a few things need to be adapted to use Jupyter) : the first works
var('x,y,s,t')
h(x,y)= x*y^2/(x^2+y^4)
cm = colormaps.Blues
def c(x,y):
return 0.6+x*y^2/(x^2+y^4+0.005)# Colorier ceci pose des problèmes, à cause de la singularité.
S=plot3d(h,(x,-1,1),(y,-1,1),color = (c,cm), opacity=1, mesh=1)
show(S)
C=contour_plot(h, (x,-1, 1), (y,-1, 1),cmap='Blues',linestyles='solid', colorbar=True)
show(C,figsize=4)
While the second, below, does not work as I would like to
h(x,y)= y/(x^2+y^2)
cm = colormaps.Spectral
def c(x,y):
return float(y/(x^2 + y^2+0.005))# Colorier ceci pose des problèmes, à cause de la singularité.
S=plot3d(h,(x,-1,1),(y,-1,1),color = (c,cm), opacity=1, mesh=1)
show(S, frame_aspect_ratio=[20,20,1])
C=contour_plot(h,(x,-1.5,1.5),(y,-1.5,1.5), cmap = "Spectral",
contours = [-2,-1, -0.5,-0.25,0,0.25,0.5,1,2], colorbar = True,
axes = True,
labels = True, label_colors='black',
label_inline=True, label_fontsize=8,
gridlines = True, axes_labels=['$x$','$y$'])
show(C,figsize=8)
I tried a few things, among other, what can be found https://ask.sagemath.org/question/7581/use-a-colormap-for-implicit_plot3d/[here (old post)](https://ask.sagemath.org/question/7581/use-a-colormap-for-implicit_plot3d/), but the discontinuity seems to cause some problems.
Suggestions?JCThu, 16 May 2019 03:12:51 +0200https://ask.sagemath.org/question/46541/How to color a 3d plot by z-level?https://ask.sagemath.org/question/8964/how-to-color-a-3d-plot-by-z-level/I'd like to color a 3d plot based on z-level. I think this is easy to do in Maple or Mathematica, but I've been searching the web for help on doing this in Sage and can't find anything to help with plot3d or implicit_plot3d.
Here's the implicit_plot3d I'm using.
var('x,y,z')
implicit_plot3d(x^2-y^2*z == 0,(x,-4,4),(y,-4,4),(z,-4,4)).show(mesh=True)
Also, are there color maps in Sage that produce plots with colors and lighting similar to the default in Mathematica?
calc314Wed, 09 May 2012 23:27:40 +0200https://ask.sagemath.org/question/8964/Coloring surfaces in plot3dhttps://ask.sagemath.org/question/9068/coloring-surfaces-in-plot3d/I'm really new with sage, and what I would like is to color a graph from plot3d according to some function (specifically, I would want the hue to vary with the magnitude of the gradient). Is there some way of doing this easily?hihoWed, 12 Sep 2012 18:16:12 +0200https://ask.sagemath.org/question/9068/