sagemath中,使用list_plot()函数画散点图时,默认情况下的点的大小较小。
示例:
a=range(10)
b=(random()*20 for _ in range(10))
array=[]
plot1 = list_plot(zip(a,b),color=(0,.5,1),marker='o',ticks=[range(10),range(20)],legend_label='Original Data Points')
plot1.axes_labels(['x coordinate ','y coordinate'])
plot1.axes_labels_size(1.2)
plot1.legend(True)
plot1.show(frame=True)
对比在python的matplotlib中,是通过markersize调节marker的大小:参考1 参考2
但在sagemath的list_plot中,不能用该参数调节。
如果将 上例中的函数改为:
plot1 = list_plot(zip(a,b),color=(0,.5,1),marker='o',ticks=[range(10),range(20)],legend_label='Original Data Points',markersize=50)
这里会提示:
verbose 0 (163: primitive.py, options) WARNING: Ignoring option 'markersize'=50
verbose 0 (163: primitive.py, options)
The allowed options for Point set defined by 10 point(s) are:
alpha How transparent the point is.
faceted If True color the edge of the point. (only for 2D plots)
hue The color given as a hue.
legend_color The color of the legend text
legend_label The label for this item in the legend.
marker the marker symbol for 2D plots only (see documentation of plot() for details)
markeredgecolorthe color of the marker edge (only for 2D plots)
rgbcolor The color as an RGB tuple.
size How big the point is (i.e., area in points^2=(1/72 inch)^2).
zorder The layer level in which to draw
verbose 0 (163: primitive.py, options) WARNING: Ignoring option 'markersize'=50
verbose 0 (163: primitive.py, options)
The allowed options for Point set defined by 10 point(s) are:
alpha How transparent the point is.
faceted If True color the edge of the point. (only for 2D plots)
hue The color given as a hue.
legend_color The color of the legend text
legend_label The label for this item in the legend.
marker the marker symbol for 2D plots only (see documentation of plot() for details)
markeredgecolorthe color of the marker edge (only for 2D plots)
rgbcolor The color as an RGB tuple.
size How big the point is (i.e., area in points^2=(1/72 inch)^2).
zorder The layer level in which to draw
verbose 0 (163: primitive.py, options) WARNING: Ignoring option 'markersize'=50
verbose 0 (163: primitive.py, options)
The allowed options for Point set defined by 10 point(s) are:
alpha How transparent the point is.
faceted If True color the edge of the point. (only for 2D plots)
hue The color given as a hue.
legend_color The color of the legend text
legend_label The label for this item in the legend.
marker the marker symbol for 2D plots only (see documentation of plot() for details)
markeredgecolorthe color of the marker edge (only for 2D plots)
rgbcolor The color as an RGB tuple.
size How big the point is (i.e., area in points^2=(1/72 inch)^2).
zorder The layer level in which to draw
可以看到这里提示markersize=50的设置被忽略,给出的10个参数中调节大小的是size参数,所以,将list_plot()函数中的参数设置为size,设置size=30:
a=range(10)
b=(random()*20 for _ in range(10))
array=[]
plot1 = list_plot(zip(a,b),color=(0,.5,1),marker='o',ticks=[range(10),range(20)],legend_label='Original Data Points',size=30)
plot1.axes_labels(['x coordinate ','y coordinate'])
plot1.axes_labels_size(1.2)
plot1.legend(True)
plot1.show(frame=True)
显示画出的点增大为30:
根据 sage手册 page:84的list_plot参数设置,可参考plot()的关键字的设置。
help(plot)
显示关于size的部分:
The algorithm used to insert extra points is actually pretty
simple. On the picture drawn by the lines below::
sage: p = plot(x^2, (-0.5, 1.4)) + line([(0,0), (1,1)], color='green')
sage: p += line([(0.5, 0.5), (0.5, 0.5^2)], color='purple')
sage: p += point(((0, 0), (0.5, 0.5), (0.5, 0.5^2), (1, 1)), color='red', pointsize=20)
sage: p += text('A', (-0.05, 0.1), color='red')
sage: p += text('B', (1.01, 1.1), color='red')
sage: p += text('C', (0.48, 0.57), color='red')
sage: p += text('D', (0.53, 0.18), color='red')
sage: p.show(axes=False, xmin=-0.5, xmax=1.4, ymin=0, ymax=2)
也可通过pointsize调节,将pointsize设置为pointsize=50:
a=range(10)
b=(random()*20 for _ in range(10))
array=[]
plot1 = list_plot(zip(a,b),color=(0,.5,1),marker='o',ticks=[range(10),range(20)],legend_label='Original Data Points',pointsize=50)
plot1.axes_labels(['x coordinate ','y coordinate'])
plot1.axes_labels_size(1.2)
plot1.legend(True)
plot1.show(frame=True)
设置pointsize=50的效果: