1 <?xml version="1.0" encoding="UTF-8"?>
3 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4 * Copyright (C) INRIA - Fabrice Leray
5 * Copyright (C) 2012 - 2016 - Scilab Enterprises
6 * Copyright (C) 2018 - 2019 - Samuel GOUGEON
8 * This file is hereby licensed under the terms of the GNU GPL v2.0,
9 * pursuant to article 5.3.4 of the CeCILL v.2.1.
10 * This file was originally licensed under the terms of the CeCILL v2.1,
11 * and continues to be available under such terms.
12 * For more information, see the COPYING file which you should have received
13 * along with this program.
16 <refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"
17 xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns4="http://www.w3.org/1999/xhtml"
18 xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook"
19 xmlns:scilab="http://www.scilab.org" xml:id="plot" xml:lang="pt">
21 <refname>plot</refname>
22 <refpurpose>Esboço 2d</refpurpose>
25 <title>Seqüência de Chamamento</title>
31 plot(x, list(fun, param))
33 plot(.., LineSpec, GlobalProperty)
34 plot(x1, y1, LineSpec1, x2,y2,LineSpec2,...xN, yN, LineSpecN, GlobalProperty1,.. GlobalPropertyM)
35 plot(x1,fun1,LineSpec1, x2,y2,LineSpec2,...xN,funN,LineSpecN, GlobalProperty1, ..GlobalPropertyM)
40 <refsection role="parameters">
41 <title>Parâmetros</title>
46 <para>uma matriz ou vetor de reais. Se omitido, é assumido como
47 sendo o vetor <literal>1:n</literal> onde <literal>n</literal> é o
48 número de pontos de curva dado pelo parâmetro
57 uma matriz de reais ou um vetor.
62 <term>fun, fun1</term>
65 função definida como um macro ou uma primitiva, como em
66 <literal>plot(x, sin)</literal>
69 If the function to plot needs some parameters as input arguments, the
70 function and its parameters can be specified through a list, as in
71 <literal>plot(x, list(delip, -0.4))</literal>
78 <para>este argumento opcional deve ser usado como um atalho para
79 especificar um modo de desenhar uma linha. Podemos ter um
80 <literal>LineSpec</literal> por<literal> y</literal> ou
81 <literal>{x,y}</literal> previamente entrados. As opções
82 <literal>LineSpec</literal> lidam com os especificadores LineStyle,
83 Marker e Color (ver <link linkend="LineSpec">LineSpec</link>). Estes
84 especificadores determinam o estilo de linha, de marcas e a cor das
90 <term>GlobalProperty</term>
92 <para>este argumento opcional representa uma seqüência de pares de
93 declarações <literal>{PropertyName,PropertyValue}</literal> tque
94 define propriedades globais de objetos a serem aplicadas a todas as
95 curvas criadas pelo esboço. Para uma visualização completa de das
96 propriedades disponíveis veja <link linkend="GlobalProperty">GlobalProperty</link>.
104 "ln" | "nl" | "ll" : 2-character word made of "l" standing for
105 "<emphasis role="bold">L</emphasis>ogarithmic" or/and "n" standing for
106 "<emphasis role="bold">N</emphasis>ormal". The first character applies to
107 the X axis, the second to the Y axis. Hence, "ln" means that the X axis
108 is logarithmic and the Y axis is normal. The default is "nn":
109 both axes in normal scales.
112 <literal>logflag</literal> must be used after <literal>axes_handle</literal>
113 (if any) and before the first curve's data <literal>x</literal> or
114 <literal>y</literal> or <literal>fun</literal>.
115 It applies to all curves drawn by the <literal>plot(…)</literal> instruction.
120 <term>axes_handle</term>
122 <para>este argumento opcional força o esboço a aparecer dentro dos
123 eixos selecionados fornecidos por <literal>axes_handle</literal> ao
124 invés dos eixos correntes (ver <link linkend="gca">gca</link>).
130 <refsection role="description">
131 <title>Descrição</title>
133 <literal>plot</literal> esboça um conjunto de curvas 2d.
134 <literal>plot</literal> foi reconstruído para lidar melhor com a sintaxe
135 do Matlab. Para melhorar a compatibilidade gráfica com o Matlab, utilize
136 <literal>plot</literal> (ao invés de <link linkend="plot2d">plot2d</link>).
138 <para>Especificação de entrada de dados:</para>
139 <para>Neste parágrafo, para sermos mais claros, não mencionaremos os
140 argumentos opcionais <literal>LineSpec</literal> ou
141 <literal>GlobalProperty</literal> já que eles não interferem na entrada de
142 dados (exceto pelas propriedades <literal>"Xdata"</literal>,
143 <literal>"Ydata"</literal> e <literal>"Zdata"</literal>,
144 ver <link linkend="GlobalProperty">GlobalProperty</link>). É assumido que todos
145 estes argumentos podem estar presentes também.
148 Se <literal>y</literal> é um vetor, plot(y) esboça um vetor
149 <literal>y</literal> versus o vetor
150 <literal>1:size(y,'*')</literal>.
153 Se <literal>y</literal> é uma matriz, plot(y) esboça cada coluna de
154 <literal>y</literal> versus o vetor <literal>1:size(y,1)</literal>.
157 Se <literal>x</literal> e <literal>y</literal> são vetores,
158 plot(x,y) esboça o vetor <literal>y</literal> versus o vetor
159 <literal>x</literal>. Os vetores <literal>x</literal> e
160 <literal>y</literal> devem ter o mesmo número de entradas.
163 Se <literal>x</literal> é um vetor e <literal>y</literal> uma matriz
164 plot(x,y) esboça cada coluna de <literal>y</literal> versus o vetor
165 <literal>x</literal>. Neste caso, o número de colunas de
166 <literal>y</literal> deve ser igual ao número de entradas de
167 <literal>x</literal>.
170 Se <literal>x</literal> e <literal>y</literal> são matrizes,
171 plot(x,y) esboça cada coluna de <literal>y</literal> versus a coluna
172 correspondente de <literal>x</literal>. Neste caso, os tamanhos
173 <literal>x</literal> e <literal>y</literal> devem ser os mesmos.
176 Finalmente, se apenas <literal>x</literal> ou <literal>y</literal> é
177 uma matriz, o vetor é esboçado versus cada linha ou cada coluna da matriz.
178 A escolha é feita dependendo se a dimensão de linha ou coluna do vetor
179 coincide com a dimensão de linha ou coluna da matriz. No caso de uma
180 matriz quadrada (apenas <literal>x</literal> ou penas
181 <literal>y</literal>), a prioridade é dada a colunas ao invés de linhas
182 (ver exemplos abaixo).
185 <literal>y</literal> também pode ser uma função definida como um
186 macro ou uma primitiva. Neste caso, os dados <literal>x</literal> devem
187 ser fornecidos (como um vetor ou uma matriz) e a computação correspondente
188 de <literal>y(x)</literal> é feita implicitamente.
191 Os argumentos <literal>LineSpec</literal> e
192 <literal>GlobalProperty</literal> devem ser utilizados para customizar o
193 esboço. Aqui está uma lista completa das opções disponíveis.
197 <term>LineSpec</term>
199 <para>esta opção pode ser utilizada para se especificar, de um modo
200 curto e fácil, como as curvas são desenhadas. Deve sempre ser um
201 string contendo referências aos especificadores LineStyle, Marker e
204 <para>Essas referências devem ser ajustadas denro do string (a ordem
205 não é importante) de modo a não ter ambigüidades. Por exemplo, para
206 especificar uma linha vermelha de traço longo com marcas de rombos,
207 pode-se escrever : <literal>'r--d'</literal> ou
208 <literal>'--dire'</literal> ou <literal>'--reddiam'</literal> ou
209 outra sentença sem ambigüidade... ou de modo completo
210 <literal>'diamondred--'</literal> (ver <link linkend="LineSpec">LineSpec</link>).
212 <para>Note que os estilos de linha e marcas (e tamanhos) e as cores,
213 podem ser (re*)ajustados através das propriedades da entidade
214 poligonal (ver <link linkend="polyline_properties">polyline_properties</link>).
219 <term>GlobalProperty</term>
221 <para>esta opção pode ser utilizada para especificar como as linhas
222 serão desenhadas com mais opções que via
223 <literal>LineSpec</literal>. Deve sempre ser um par de declarações
224 constituidos de um string definindo <literal>PropertyName</literal>,
225 (nome da propriedade) e seu valor associado
226 <literal>PropertyValue</literal> (que pode ser um string, um inteiro
227 ou qualquer outra coisa... dependendo do tipo de
228 <literal>PropertyName</literal>). Utilizando-se
229 <literal>GlobalProperty</literal>, pode-se ajustar várias
230 propriedades : todas as propriedades disponíveis via LineSpec e
231 mais: a cor da marca (plano de fundo e primeiro plano), a
232 visibilidade, o recorte e a espessura das curvas.
233 (ver <link linkend="GlobalProperty">GlobalProperty</link>)
236 Note que todas as propriedades podem ser (re-)ajustadas
237 através das propriedades de entidades poligonais
238 (ver <link linkend="polyline_properties">polyline_properties</link>).
244 <refsection role="description">
245 <title>Observações </title>
246 <para>Por padrão, esboços sucessivos são superpostos. Para limpar o esboço
247 anterior, use <literal>clf()</literal>. Para habilitar o modo
248 <literal>auto_clear</literal> (limpeza automática) como modo padrão, edite
249 seus eixos fazendo o seguinte:
251 <para>da=gda();</para>
252 <para>da.auto_clear = 'on'</para>
254 Para uma melhor exibição, a função <literal>plot</literal> pode
255 modificar a propriedade <literal>box</literal> de seu Axes (eixos) raíze.
256 Isto acontece quando uma entidade Axes é criada por uma chamada a
257 <literal>plot</literal> ou é vazia antes da chamada. Se um dos eixos é
258 centrado na origem, box é desabilitado. Em caso contrário, box é
261 <para>Para mais informações sobre a propriedade box e sobre o
262 posicionamento dos eixos, veja <link linkend="axes_properties">axes_properties</link>
264 <para>Uma tabela de cores padrão é utilizada para colorir as curvas
265 esboçadas quando você não especifica as cores. Ao desenhar linhas
266 múltiplas, o comando plot automaticamente atribui as cores abaixo de modo
267 cíclico. Aqui estão as cores utilizadas:
269 <informaltable border="1">
271 <th> <literal>R</literal> </th>
272 <th> <literal>G</literal> </th>
273 <th> <literal>B</literal> </th>
275 <tr> <td>0.</td> <td>0.</td> <td>1.</td> </tr>
276 <tr> <td>0.</td> <td>0.5</td> <td>0.</td> </tr>
277 <tr> <td>1.</td> <td>0.</td> <td>0.</td> </tr>
278 <tr> <td>0.</td> <td>0.75</td> <td>0.75</td> </tr>
279 <tr> <td>0.75</td> <td>0.</td> <td>0.75</td> </tr>
280 <tr> <td>0.75</td> <td>0.75</td> <td>0.</td> </tr>
281 <tr> <td>0.25</td> <td>0.25</td> <td>0.25</td> </tr>
285 Entre com o comando <literal>plot</literal> para visualizar uma
289 <refsection role="examples">
290 <title>Exemplos</title>
292 <emphasis role="bold">Choosing the normal or logarithmic plotting mode:</emphasis>
294 <programlisting role="example"><![CDATA[
295 gda().grid = [1 1]*color("grey70");
296 title(gda(), "fontsize", 3, "color", "lightseagreen", "fontname", "helvetica bold");
298 x = linspace(1e-1,100,1000);
301 G = exp(-((x-xm)/dx).^2/2)*30;
304 subplot(2,2,1), plot(x, G), title("plot(x, y)")
305 subplot(2,2,2), plot("ln", x, G), title("semilog-x : plot(""ln"", x, y)"); gca().sub_ticks(1) = 8;
306 subplot(2,2,3), plot("nl", x, G), title("semilog-y : plot(""nl"", x, y)"); gca().sub_ticks(2) = 8;
307 subplot(2,2,4), plot("ll", x, G), title("loglog : plot(""ll"", x, y)"); gca().sub_ticks = [8 8];
312 gda().grid = [1 1]*color("grey70");
313 title(gda(), "", "fontsize", 3, "color", "lightseagreen", "fontname", "helvetica bold");
315 x = linspace(1e-1,100,1000);
318 G = exp(-((x-xm)/dx).^2/2)*30;
320 subplot(2,2,1), plot(x, G), title("plot(x, y)")
321 subplot(2,2,2), plot("ln", x, G), title("semilog-x : plot(""ln"", x, y)")
322 gca().sub_ticks(1) = 8;
323 subplot(2,2,3), plot("nl", x, G), title("semilog-y : plot(""nl"", x, y)")
324 gca().sub_ticks(2) = 8;
325 subplot(2,2,4), plot("ll", x, G), title("loglog : plot(""ll"", x, y)")
326 gca().sub_ticks = [8 8];
328 gcf().axes_size = [750 520];
333 <emphasis role="bold">Simple plot of a single curve:</emphasis>
335 <programlisting role="example"><![CDATA[
336 // Default abscissae = indices
338 plot(sin(0:0.1:2*%pi))
341 // With explicit abscissae:
345 xlabel("Specified abscissae")
348 // Default abscissae = indices
350 plot(sin(0:0.1:2*%pi))
353 // With explicit abscissae:
357 xlabel("Specified abscissae")
359 gcf().axes_size = [700 350];
362 <emphasis role="bold">Multiple curves with shared abscissae:</emphasis>
363 Y: 1 column = 1 curve:
365 <programlisting role="example"><![CDATA[
368 plot(x, [sin(x) sin(2*x) sin(3*x)])
372 plot(x,[sin(x) sin(2*x) sin(3*x)])
374 gcf().axes_size = [700 350];
377 <emphasis role="bold">
378 Specifying a macro or a builtin instead of explicit ordinates:
381 <programlisting role="example"><![CDATA[
383 subplot(2,2,1) // sin() is a builtin
384 plot(1:0.1:10, sin) // <=> plot(1:0.1:10, sin(1:0.1:10))
385 title("plot(x, sin)", "fontsize",3)
388 deff('y = myFun(x)','y = x + rand(x)')
390 plot(-3:0.1:5, myFun)
391 title("plot(x, myFun)", "fontsize",3)
393 // With functions with parameters:
395 plot(1:0.05:7, list(delip, -0.4)) // <=> plot(1:0.05:7, delip(1:0.05:7,-0.4) )
396 title("plot(x, list(delip,-0.4))", "fontsize",3)
398 function Y = myPow(x,p)
403 Y(:,i) = Y(:,i)/m(i);
408 plot(x, list(myPow,1:5))
409 title("plot(x, list(myPow,1:5))", "fontsize",3)
411 <scilab:image><![CDATA[
412 subplot(2,2,1) // sin() is a builtin
413 plot(1:0.1:10, sin) // <=> plot(1:0.1:10, sin(1:0.1:10))
414 title("plot(x,sin)", "fontsize",3)
417 deff('y = myFun(x)','y = x + rand(x)')
419 plot(-3:0.1:5, myFun)
420 title("plot(x, myFun)", "fontsize",3)
422 // With functions with parameters:
424 plot(1:0.05:7, list(delip, -0.4)) // <=> plot(1:0.05:7, delip(1:0.05:7,-0.4) )
425 title("plot(x, list(delip,-0.4))", "fontsize",3)
427 function Y = myPow(x,p)
432 Y(:,i) = Y(:,i)/m(i);
437 plot(x, list(myPow,1:5))
438 title("plot(x, list(myPow,1:5))", "fontsize",3)
440 gcf().axes_size = [730 500];
443 <emphasis role="bold">Setting curves simple styles when calling plot():</emphasis>
445 <programlisting role="example"><![CDATA[
447 t = -%pi:%pi/20:2*%pi;
448 // sin() : in Red, with O marks, without line
449 // cos() : in Green, with + marks, with a solid line
450 // gaussian: in Blue, without marks, with dotted line
451 gauss = 1.5*exp(-(t/2-1).^2)-1;
453 plot(t,sin,'ro', t,cos,'g+-', t,gauss,':b')
455 <scilab:image><![CDATA[
456 t = -%pi:%pi/20:2*%pi;
457 // sin() : in Red, with O marks, without line
458 // cos() : in Green, with + marks, with a solid line
459 // gaussian: in Blue, without marks, with dotted line
460 gauss = 1.5*exp(-(t/2-1).^2)-1;
462 plot(t,sin,'ro', t,cos,'g+-', t,gauss,':b')
464 gcf().axes_size = [800 400];
468 Vertical segments between two curves, with automatic colors, and using Global properties
469 for markers styles. Targeting a defined axes.
471 <programlisting role="example"><![CDATA[
474 ax3 = gca(); // We will draw here later
475 xsetech([0 0 0.7 1]) // Defines the first Axes area
477 // Tuning markers properties
478 plot([t ;t],[sin(t) ;cos(t)],'marker','d','markerFaceColor','green','markerEdgeColor','yel')
480 // Targeting a defined axes
483 <scilab:image><![CDATA[
486 ax3 = gca(); // We will draw here later
487 xsetech([0 0 0.7 1]) // Defines the first Axes area
489 // Tuning markers properties
490 plot([t ;t],[sin(t) ;cos(t)],'marker','d','markerFaceColor','green','markerEdgeColor','yel')
492 // Targeting a defined axes
495 gcf().axes_size = [800 400];
501 <emphasis role="bold">Case of a non-square Y matrix:</emphasis>
502 When it is consistent and required, X or/and Y data are
503 automatically transposed in order to become plottable.
505 <programlisting role="example"><![CDATA[
513 // Only one matching possibility case: how to make 4 identical plots in 4 manners...
514 // x is 1x4 (vector) and y is 4x5 (non square matrix)
515 subplot(221); plot(x', y , "o-"); // OK as is
516 subplot(222); plot(x , y , "o-"); // x is transposed
517 subplot(223); plot(x', y', "o-"); // y is transposed
518 subplot(224); plot(x , y', "o-"); // x and y are transposed
527 // Only one matching possibility case: how to make 4 identical plots in 4 manners...
528 // x is 1x4 (vector) and y is 4x5 (non square matrix)
529 subplot(221); plot(x', y , "o-"); // OK as is
530 subplot(222); plot(x , y , "o-"); // x is transposed
531 subplot(223); plot(x', y', "o-"); // y is transposed
532 subplot(224); plot(x , y', "o-"); // x and y are transposed
535 <emphasis role="bold">Case of a square Y matrix, and X implicit or square:</emphasis>
537 <programlisting role="example"><![CDATA[
544 subplot(231), plot(t,"o-") , title("plot(t)", "fontsize",3)
545 subplot(234), plot(t',"o-"), title("plot(t'')", "fontsize",3)
547 subplot(232), plot(t,t,"o-") , title("plot(t, t)", "fontsize",3)
548 subplot(233), plot(t,t',"o-"), title("plot(t,t'')", "fontsize",3)
550 subplot(235), plot(t', t,"o-"), title("plot(t'', t)", "fontsize",3)
551 subplot(236), plot(t', t',"o-"), title("plot(t'', t'')", "fontsize",3)
553 for i=1:6, gcf().children(i).data_bounds([1 3]) = 0.5; end
562 subplot(231), plot(t,"o-") , title("plot(t)", "fontsize",3)
563 subplot(234), plot(t',"o-"), title("plot(t'')", "fontsize",3)
565 subplot(232), plot(t,t,"o-") , title("plot(t, t)", "fontsize",3)
566 subplot(233), plot(t,t',"o-"), title("plot(t,t'')", "fontsize",3)
568 subplot(235), plot(t', t,"o-"), title("plot(t'', t)", "fontsize",3)
569 subplot(236), plot(t', t',"o-"), title("plot(t'', t'')", "fontsize",3)
571 for i=1:6, gcf().children(i).data_bounds([1 3]) = 0.5; end
573 gcf().axes_size = [800 450];
576 <emphasis role="bold">Special cases of a matrix X and a vector Y:</emphasis>
578 <programlisting role="example"><![CDATA[
586 subplot(221), plot(X, y, "o-"), title("plot(X, row)", "fontsize",3)
587 // equivalent to plot(t, [1 1 1 1; 2 2 2 2; 3 3 3 3; 4 4 4 4])
588 subplot(223), plot(X, y', "o-"), title("plot(X, col) (row = col'')", "fontsize",3)
589 subplot(222), plot(X',y, "o-"), title("plot(X'', row)", "fontsize",3)
590 subplot(224), plot(X',y', "o-"), title("plot(X'', col) (row = col'')", "fontsize",3)
592 for i = 1:4, gcf().children(i).data_bounds([1 3]) = 0.5; end
602 subplot(221), plot(X, y, "o-"), title("plot(X, row)", "fontsize",3)
603 // equivalent to plot(t, [1 1 1 1; 2 2 2 2; 3 3 3 3; 4 4 4 4])
604 subplot(223), plot(X, y', "o-"), title("plot(X, col) (row = col'')", "fontsize",3)
605 subplot(222), plot(X',y, "o-"), title("plot(X'', row)", "fontsize",3)
606 subplot(224), plot(X',y', "o-"), title("plot(X'', col) (row = col'')", "fontsize",3)
608 for i = 1:4, gcf().children(i).data_bounds([1 3]) = 0.5; end
612 <emphasis role="bold">Post-tuning Axes and curves:</emphasis>
614 <programlisting role="example"><![CDATA[
616 plot(x-4,sin(x),x+2,cos(x))
618 // axis centered at (0,0)
619 a=gca(); // Handle on axes entity
620 a.x_location = "origin";
621 a.y_location = "right";
624 // Some operations on entities created by plot ...
625 a.children // list the children of the axes : here it is an Compound child composed of 2 entities
626 poly1= a.children.children(2); //store polyline handle into poly1
627 poly1.foreground = 4; // another way to change the style...
628 poly1.thickness = 3; // ...and the thickness of a curve.
629 poly1.clip_state='off' // clipping control
634 plot(x-4,sin(x),x+2,cos(x))
636 a.x_location = "origin";
637 a.y_location = "origin";
640 poly1 = a.children.children(2);
641 poly1.foreground = 4;
643 poly1.clip_state='off'
647 <refsection role="see also">
648 <title>Ver Também</title>
649 <simplelist type="inline">
651 <link linkend="plot2d">plot2d</link>
654 <link linkend="plot2d2">plot2d2</link>
657 <link linkend="plot2d3">plot2d3</link>
660 <link linkend="plot2d4">plot2d4</link>
663 <link linkend="param3d">param3d</link>
666 <link linkend="surf">surf</link>
669 <link linkend="scf">scf</link>
672 <link linkend="clf">clf</link>
675 <link linkend="xdel">xdel</link>
678 <link linkend="delete">delete</link>
681 <link linkend="LineSpec">LineSpec</link>
684 <link linkend="color_list">Cores nomeadas</link>
687 <link linkend="GlobalProperty">GlobalProperty</link>
691 <refsection role="history">
692 <title>Histórico</title>
695 <revnumber>6.0.1</revnumber>
697 The "color"|"foreground", "markForeground", and "markBackground" GlobalProperty
698 colors can now be chosen among the full predefined colors list, or by
699 their "#RRGGBB" hexadecimal codes, or by their indices in the colormap.
703 <revnumber>6.0.2</revnumber>
705 Plotting a function fun(x, params) with input parameters is now possible with
706 plot(x, list(fun, params)).
710 <revnumber>6.1.0</revnumber>
712 logflag option added.