如何在Scilab中扩展多个点的图的轴?

时间:2017-05-09 18:43:21

标签: matlab plot point scilab

我使用的是Scilab 5.5.2。绘制多个点。这是我的剧本试图在2D中绘制4个点:

u = [1,2;2,1;3,1;4,5;5,1]

clf; plot(u,"*r")

我试图在2D中绘制的点是(1,2),(2,1),(3,1)和(5,1)。

我使用“u”作为矢量来存储坐标。该脚本生成此图像:

enter image description here

我想扩展x轴和y轴以获得“通常”图形。我试着这样做:

x=[0:10]

u = [1,2;2,1;3,1;4,5;5,1]

clf; plot(x,u,"*r")

但是,我收到此错误消息:

WARNING: Transposing row vector X to get compatible dimensions
 !--error 10000 
plot: Wrong size for input arguments #2 and #3: Incompatible dimensions.
at line     147 of function checkXYPair called by :  
at line     236 of function plot called by :  
clf; plot(x,u,"*r")
at line       9 of exec file called by :    
exec('poole-exemple.sci')

更重要的是,我的情节有些奇怪。我的脚本生成了我不想要的点。如果你看图像,你会在图上看到(4,4)或(1,1)点。我不想要这个,我不知道为什么会这样。

有谁知道如何帮助我?

1 个答案:

答案 0 :(得分:0)

数据范围

您想要更改数据边界,这是执行gca后可访问的many axes properties之一,"获取当前轴"。像这样:

plot(u(:,1), u(:, 2), "*r" )
a = gca()
a.data_bounds = [0 0; 10 7]

data_bounds属性的格式为[xmin,ymin; xmax,ymax]。

根据数据,这是设置它的更好方法:

a.data_bounds = [min(u, 'r') - 1; max(u, 'r') + 1]

这将最小数据值的最小界限设置为1,最大值设置为最大值+ 1。

不正确的分数

documentation解释plot命令的参数是:x值的向量和y值的向量:分开,不在一个矩阵中。您的数据应该是

plot(u(:,1), u(:, 2), "*r" )

不是plot(u, "*r")