Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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 : 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(j,(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), but the discontinuity seems to cause some problems.

Suggestions?

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(j,(x,-1.5,1.5),(y,-1.5,1.5), 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), but the discontinuity seems to cause some problems.

Suggestions?

click to hide/show revision 3
retagged

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), but the discontinuity seems to cause some problems.

Suggestions?