Question

Hi I have a couple of Scilab questions which I'm hoping someone will be able to answer.

Firstly, I need to display certain data points on my graph which is part of a different loop. Is there an simple way to do so? maybe something like

xstring(x,y,[value of x], [value of y])?

when I do this, it always displays the whole x and y matrix instead of just the value at that one point

Secondly, I have separate files that I would like to concatenate into 1 pdf file? I am not sure how to do this.

z = 1:3

scf(z)
plot(x,Y)

xs2pdf(z,filename)?

I've tried this but I always only get the last image saved into the pdf.

Thank you in advanced

Was it helpful?

Solution

Display data points

// Some function
x = 1:10;
y = x^2;

plot(x,y);

//Display fifth number
i = 5;

// Create a nice string label
stringToDisplay = sprintf("X: %d, Y: %d", x(i), y(i));

// Put it at the correct spot on the plot
xstring( x(i), y(i), stringToDisplay );

The nicest thing would to place it in a function:

function plotMyLabel(i)
    stringToDisplay = sprintf("X: %d, Y: %d", x(i), y(i));
    xstring( x(i), y(i), stringToDisplay );
endfunction

Multiple plots

You could create a figure with multiple subplots and export it. See subplot documentation of scilab.

//plot first graph
subplot(1,2,1);

plot(x1,y1);

//plot second graph 
subplot(1,2,2);

plot(x2,y2);

// Format the figure at will
fig = gcf();

fig.figure_size=[1200, 800];
fig.children.margins = [0.05, 0.05, 0.05, 0.05];

//export to file
xs2pdf(fig, 'my_out_file');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top