Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You might be interested in the answers to this question about zordering..

You can choose how to zorder (i.e. choose the "depth" of an image") by calling set_zorder on the component objects. For example:

sage: x_coords = [cos(t)^3 for t in srange(0, 2*pi, 0.02)]
sage: y_coords = [sin(t)^3 for t in srange(0, 2*pi, 0.02)]
sage: h1 = list_plot(zip(x_coords, y_coords))
sage: x,y = var('x,y')
sage: h2 = density_plot(sin(x)*sin(y), (x, -2, 2), (y, -2, 2), cmap='jet')
sage: h = h1+h2
sage: list(h)
[Point set defined by 315 point(s), DensityPlot defined by a 25 x 25 data grid]
sage: h[0].set_zorder(10)
sage: show(h)

image description

But I have to admit that it doesn't look like all graphics objects correctly support zordering the way they should:

sage: h[1].set_zorder(20)
sage: show(h)
verbose 0 (138: primitive.py, options) WARNING: Ignoring option 'zorder'=20
verbose 0 (138: primitive.py, options) 
The allowed options for DensityPlot defined by a 25 x 25 data grid are:
    cmap           the name of a predefined colormap,
                       a list of colors or an instance of a
                       matplotlib Colormap. Type: import matplotlib.cm; matplotlib.cm.datad.keys()
                       for available colormap names.
    interpolation  What interpolation method to use                            
    plot_points    How many points to use for plotting precision

You might be interested in the answers to this question about zordering..

You can choose how to zorder (i.e. choose the "depth" of an image") image) by calling set_zorder on the component objects. For example:

sage: x_coords = [cos(t)^3 for t in srange(0, 2*pi, 0.02)]
sage: y_coords = [sin(t)^3 for t in srange(0, 2*pi, 0.02)]
sage: h1 = list_plot(zip(x_coords, y_coords))
sage: x,y = var('x,y')
sage: h2 = density_plot(sin(x)*sin(y), (x, -2, 2), (y, -2, 2), cmap='jet')
sage: h = h1+h2
sage: list(h)
[Point set defined by 315 point(s), DensityPlot defined by a 25 x 25 data grid]
sage: h[0].set_zorder(10)
sage: show(h)

image description

But I have to admit that it doesn't look like all graphics objects correctly support zordering the way they should:

sage: h[1].set_zorder(20)
sage: show(h)
verbose 0 (138: primitive.py, options) WARNING: Ignoring option 'zorder'=20
verbose 0 (138: primitive.py, options) 
The allowed options for DensityPlot defined by a 25 x 25 data grid are:
    cmap           the name of a predefined colormap,
                       a list of colors or an instance of a
                       matplotlib Colormap. Type: import matplotlib.cm; matplotlib.cm.datad.keys()
                       for available colormap names.
    interpolation  What interpolation method to use                            
    plot_points    How many points to use for plotting precision

You might be interested in the answers to this question about zordering..

You can choose how to zorder (i.e. choose the "depth" of an image) by calling set_zorder on the component objects. resulting graphics objects [not on the plots]. For example:

sage: x_coords = [cos(t)^3 for t in srange(0, 2*pi, 0.02)]
sage: y_coords = [sin(t)^3 for t in srange(0, 2*pi, 0.02)]
sage: h1 = list_plot(zip(x_coords, y_coords))
sage: x,y = var('x,y')
sage: h2 = density_plot(sin(x)*sin(y), (x, -2, 2), (y, -2, 2), cmap='jet')
sage: h = h1+h2
sage: list(h)
[Point set defined by 315 point(s), DensityPlot defined by a 25 x 25 data grid]
sage: h[0].set_zorder(10)
sage: show(h)

image description

But I have to admit that it doesn't look like all graphics objects correctly support zordering the way they should:

sage: h[1].set_zorder(20)
sage: show(h)
verbose 0 (138: primitive.py, options) WARNING: Ignoring option 'zorder'=20
verbose 0 (138: primitive.py, options) 
The allowed options for DensityPlot defined by a 25 x 25 data grid are:
    cmap           the name of a predefined colormap,
                       a list of colors or an instance of a
                       matplotlib Colormap. Type: import matplotlib.cm; matplotlib.cm.datad.keys()
                       for available colormap names.
    interpolation  What interpolation method to use                            
    plot_points    How many points to use for plotting precision

You might be interested in the answers to this question about zordering..

You can choose how to zorder (i.e. choose the "depth" of an image) by calling set_zorder on the resulting graphics objects [not on the plots]. For example:

sage: x_coords = [cos(t)^3 for t in srange(0, 2*pi, 0.02)]
sage: y_coords = [sin(t)^3 for t in srange(0, 2*pi, 0.02)]
sage: h1 = list_plot(zip(x_coords, y_coords))
sage: x,y = var('x,y')
sage: h2 = density_plot(sin(x)*sin(y), (x, -2, 2), (y, -2, 2), cmap='jet')
sage: h = h1+h2
sage: list(h)
[Point set defined by 315 point(s), DensityPlot defined by a 25 x 25 data grid]
sage: h[0].set_zorder(10)
sage: show(h)

image description

But I have to admit that it doesn't look like all graphics the objects correctly you might want to support zordering the way they should:

sage: h[1].set_zorder(20)
sage: show(h)
verbose 0 (138: primitive.py, options) WARNING: Ignoring option 'zorder'=20
verbose 0 (138: primitive.py, options) 
The allowed options for DensityPlot defined by a 25 x 25 data grid are:
    cmap           the name of a predefined colormap,
                       a list of colors or an instance of a
                       matplotlib Colormap. Type: import matplotlib.cm; matplotlib.cm.datad.keys()
                       for available colormap names.
    interpolation  What interpolation method to use                            
    plot_points    How many points to use for plotting precision

This is an inconvenience because it's not pretty to force it via the underlying matplotlib objects, but I might be missing something.