1 | initial version |
Asking for the doc via ?density_plot
in the sage console gives a lot of information:
Signature: density_plot(*args, **kwds)
Docstring:
"density_plot" takes a function of two variables, f(x,y) and plots
the height of the function over the specified "xrange" and "yrange"
as demonstrated below.
"density_plot(f, (xmin,xmax), (ymin,ymax), ...)"
INPUT:
* "f" -- a function of two variables
* "(xmin,xmax)" -- 2-tuple, the range of "x" values OR 3-tuple
"(x,xmin,xmax)"
* "(ymin,ymax)" -- 2-tuple, the range of "y" values OR 3-tuple
"(y,ymin,ymax)"
The following inputs must all be passed in as named parameters:
* "plot_points" -- integer (default: 25); number of points to
plot in each direction of the grid
* "cmap" -- a colormap (default: "'gray'"), 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" -- string (default: "'catrom'"), the
interpolation method to use: "'bilinear'", "'bicubic'",
"'spline16'", "'spline36'", "'quadric'", "'gaussian'", "'sinc'",
"'bessel'", "'mitchell'", "'lanczos'", "'catrom'", "'hermite'",
"'hanning'", "'hamming'", "'kaiser'"
EXAMPLES:
and so on. (Truncated.) The many doc examples are not related to the option specifying the color map...
The one subquestion about the function (being a synonym to curve, or not), is immediately cleared, density plots are done for functions from a domain inside $\mathbb R^2$ with values in $\mathbb R$. The height of a function is then "giving the color".
The colors now.
From the sage interpreter console, the default seems to be "gray"
. The question mentions red + blue, so i have to guess that some other interface is using these colors by default. Possible color schemes are in the list:
sage: import matplotlib.cm
sage: cmapList = matplotlib.cm.datad.keys()
sage: cmapList . sort()
sage: cmapList[:10]
[u'Accent',
u'Accent_r',
u'Blues',
u'Blues_r',
u'BrBG',
u'BrBG_r',
u'BuGn',
u'BuGn_r',
u'BuPu',
u'BuPu_r']
(Only the first ten shown.)
Starting from the code:
var( 'x,y' );
def f(x,y): return exp( -x^2-y^2 )
one can thus try the color maps / schemes:
density_plot( f, (x,-1,1), (y,-1,1) ) # gray
density_plot( f, (x,-1,1), (y,-1,1), cmap='Accent' )
density_plot( f, (x,-1,1), (y,-1,1), cmap='Spectral' )
density_plot( f, (x,-1,1), (y,-1,1), cmap='Blues' )
density_plot( f, (x,-1,1), (y,-1,1), cmap='brg' )
density_plot( f, (x,-1,1), (y,-1,1), cmap='brg_r' ) # brg reversed
density_plot( f, (x,-1,1), (y,-1,1), cmap='gnuplot' )
and so on.
2 | No.2 Revision |
Asking for the doc via ?density_plot
in the sage console gives a lot of information:
Signature: density_plot(*args, **kwds)
Docstring:
"density_plot" takes a function of two variables, f(x,y) and plots
the height of the function over the specified "xrange" and "yrange"
as demonstrated below.
"density_plot(f, (xmin,xmax), (ymin,ymax), ...)"
INPUT:
* "f" -- a function of two variables
* "(xmin,xmax)" -- 2-tuple, the range of "x" values OR 3-tuple
"(x,xmin,xmax)"
* "(ymin,ymax)" -- 2-tuple, the range of "y" values OR 3-tuple
"(y,ymin,ymax)"
The following inputs must all be passed in as named parameters:
* "plot_points" -- integer (default: 25); number of points to
plot in each direction of the grid
* "cmap" -- a colormap (default: "'gray'"), 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" -- string (default: "'catrom'"), the
interpolation method to use: "'bilinear'", "'bicubic'",
"'spline16'", "'spline36'", "'quadric'", "'gaussian'", "'sinc'",
"'bessel'", "'mitchell'", "'lanczos'", "'catrom'", "'hermite'",
"'hanning'", "'hamming'", "'kaiser'"
EXAMPLES:
and so on. (Truncated.) The many doc examples are not related to the option specifying the color map...
The one subquestion about the function (being a synonym to curve, or not), is immediately cleared, density plots are done for functions from a domain inside $\mathbb R^2$ with values in $\mathbb R$. The height "height" of a function is then "giving the color".
(So the graph is not a curve in plane, but a "hill in 3D", the height is picking "the right color" from the color chosen scheme.)
The colors now.
From the sage interpreter console, the default seems to be "gray"
. The question mentions red + blue, so i have to guess that some other interface is using these colors by default. Possible color schemes are in the list:
sage: import matplotlib.cm
sage: cmapList = matplotlib.cm.datad.keys()
sage: cmapList . sort()
sage: cmapList[:10]
[u'Accent',
u'Accent_r',
u'Blues',
u'Blues_r',
u'BrBG',
u'BrBG_r',
u'BuGn',
u'BuGn_r',
u'BuPu',
u'BuPu_r']
(Only the first ten shown.)
Starting from the code:
var( 'x,y' );
def f(x,y): return exp( -x^2-y^2 )
one can thus try the color maps / schemes:
density_plot( f, (x,-1,1), (y,-1,1) ) # gray
density_plot( f, (x,-1,1), (y,-1,1), cmap='Accent' )
density_plot( f, (x,-1,1), (y,-1,1), cmap='Spectral' )
density_plot( f, (x,-1,1), (y,-1,1), cmap='Blues' )
density_plot( f, (x,-1,1), (y,-1,1), cmap='brg' )
density_plot( f, (x,-1,1), (y,-1,1), cmap='brg_r' ) # brg reversed
density_plot( f, (x,-1,1), (y,-1,1), cmap='gnuplot' )
and so on.