Search code examples
plotgraphcurvescilab

Ploting a curve around some set of points in Scilab


I am trying to plot two things: (i) red points and (ii) a blue curve connecting the blue points.

So far, I was able to do that:

enter image description here

As you see, the red points are ok. However, I am unable to generate the curve connecting the blue dots. That's my code:

clf

new_points  = [- 0.2200600  
  - 0.2200600  
  - 0.2200600  
  - 0.2200600  
  - 0.2200600  
  - 0.2200599  
  - 0.2200597  
  - 0.2200591  
  - 0.2200579  
  - 0.2200556  
  - 0.2200514  
  - 0.2200442  
  - 0.2200324  
  - 0.2200136  
  - 0.2199848  
  - 0.2199418  
  - 0.2198793  
  - 0.2197904  
  - 0.2196663  
  - 0.2194962  
  - 0.2192667  
  - 0.2189613  
  - 0.2185603  
  - 0.2180398  
  - 0.2173716  
  - 0.2165222  
  - 0.2154525  
  - 0.2141168  
  - 0.2124619  
  - 0.2104269  
  - 0.2079415  
  - 0.2049255  
  - 0.2012878  
  - 0.1969249  
  - 0.1917203  
  - 0.1855427  
  - 0.1782451  
  - 0.1696631  
  - 0.1596135  
  - 0.1478930  
  - 0.1342761  
  - 0.1185137  
  - 0.1003313  
  - 0.0794268  
  - 0.0554688  
  - 0.0280942  
    0.0030937  
    0.0385276  
    0.0786788  
    0.1240594  
    0.1752250  
    0.2327776  
    0.2973683  
    0.3697002  
    0.4505314  
    0.5406784  
    0.6410192  
    0.7524970  
    0.8761234  
    1.012982   
    1.1642329  
    1.3311156]  

points = [];

for i=0.1:0.1:6.2;
    points = [points; i,cos(i)];
end;

plot(points(:,1), new_points(:, 1), "*b" );

plot(points(:,1), points(:, 2), "*r" );

a = gca();

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

How can I solve this?


Solution

  • The plot option *b says "blue asterisks".

    If you want "blue asterisks connected by a curve", use *b-

    The LineSpec documentation explains all this.

    if you specify a marker without a line style, only the marker is drawn.

    In your example * is a marker. To also have a line, specify a line style such as -.