Matplotlib recognizes the following formats to specify a color:
an RGB or RGBA tuple of float values in [0, 1] (e.g., (0.1, 0.2, 0.5) or (0.1, 0.2, 0.5, 0.3));
a hex RGB or RGBA string (e.g., '#0F0F0F' or '#0F0F0F0F');
a string representation of a float value in [0, 1] inclusive for gray level (e.g., '0.5');
one of {'b', 'g', 'r', 'c', 'm', 'y', 'k', 'w'};
a X11/CSS4 color name;
a name from the xkcd color survey; prefixed with 'xkcd:' (e.g., 'xkcd:sky blue');
one of {'tab:blue', 'tab:orange', 'tab:green', 'tab:red', 'tab:purple', 'tab:brown', 'tab:pink', 'tab:gray', 'tab:olive', 'tab:cyan'} which are the Tableau Colors from the ‘T10’ categorical palette (which is the default color cycle);
a “CN” color spec, i.e. 'C' followed by a single digit, which is an index into the default property cycle (matplotlib.rcParams['axes.prop_cycle']); the indexing occurs at artist creation time and defaults to black if the cycle does not include color.
All string specifications of color, other than “CN”, are case-insensitive.
像这样的?使用
axisbg
关键字subplot
:(当然,不是散点图,也不是黑色背景。)
一种方法是在脚本中手动设置轴背景色的默认值(请参见Customizing matplotlib):
这与Nick T改变特定
axes
对象背景颜色的方法形成对比。如果要使用相似的样式生成多个不同的绘图,并且不想继续更改不同的axes
对象,则重置默认值非常有用。注:相当于
你的问题是:
使用
axes
对象的set_facecolor(color)
方法,您已经创建了以下方法之一:您一起创建了一个图形和轴
您创建了一个图形,然后稍后创建axis/es
您使用了有状态API(如果您所做的只是几行,而特别是如果您有多个绘图,那么上面的面向对象方法会使您的工作变得更容易,因为您可以引用特定的图形、在某些轴上绘图和自定义其中一个)
然后您可以使用
set_facecolor
:作为什么颜色的提神剂:
相关问题 更多 >
编程相关推荐