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:mml="http://www.w3.org/1998/Math/MathML"
18 xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org"
19 xml:lang="ja" xml:id="plot">
21 <refname>plot</refname>
22 <refpurpose>2Dプロット</refpurpose>
25 <title>呼び出しの手順</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">
47 実数行列またはベクトル. 省略した場合, <literal>1:n</literal>であると
48 仮定されます. ただし, <literal>n</literal>は<literal>y</literal>パラメータで
62 <term>fun, fun1, ..</term>
65 handle of a function, as in <literal>plot(x, sin)</literal>.
68 If the function to plot needs some parameters as input arguments, the
69 function and its parameters can be specified through a list, as in
70 <literal>plot(x, list(delip, -0.4))</literal>
78 線を描画する手法を指定するショートカットとして使用されます.
79 <literal>LineSpec</literal>は指定済みの各<literal> y</literal> または <literal>{x,y}</literal>
81 <literal>LineSpec</literal>はLineStyle,MarkerおよびColorと同時に処理されます
82 (<link linkend="LineSpec">LineSpec</link>参照).
83 これらの指定子はプロットされた線において線の種類,マーカの種類および色を定義します.
88 <term>GlobalProperty</term>
91 グローバルオブジェクトのプロパティを定義する
92 一連の命令<literal>{PropertyName,PropertyValue}</literal>
93 を表し, このプロットで作成された全ての曲線に適用されます.
95 <link linkend="GlobalProperty">GlobalProperty</link>を参照してください.
103 "ln" | "nl" | "ll" : 2-character word made of "l" standing for
104 "<emphasis role="bold">L</emphasis>ogarithmic" or/and "n" standing for
105 "<emphasis role="bold">N</emphasis>ormal". The first character applies to
106 the X axis, the second to the Y axis. Hence, "ln" means that the X axis
107 is logarithmic and the Y axis is normal. The default is "nn":
108 both axes in normal scales.
111 <literal>logflag</literal> must be used after <literal>axes_handle</literal>
112 (if any) and before the first curve's data <literal>x</literal> or
113 <literal>y</literal> or <literal>fun</literal>.
114 It applies to all curves drawn by the <literal>plot(…)</literal> instruction.
119 <term>axes_handle</term>
122 このオプションの引数は,カレントの軸ではなく <literal>axes_handle</literal>で
123 指定した軸の内部にプロットが表示されることを指定します
124 (<link linkend="gca">gca</link>参照).
130 <refsection role="description">
133 <literal>plot</literal> は一連の二次元曲線をプロットします.
134 <literal>plot</literal> はMatlab構文との互換性を改善するために
136 グラフィックの互換性を改善するために, Matlabユーザは
137 (<link linkend="plot2d">plot2d</link>ではなく)
138 <literal>plot</literal>を使用してください.
140 <para>データエントリ仕様 :</para>
141 <para>本節では,記述を明確化するため,オプションの引数
142 <literal>LineSpec</literal>および <literal>GlobalProperty</literal>
145 (<literal>"Xdata"</literal>,
146 <literal>"Ydata"</literal> および <literal>"Zdata"</literal> プロパティを
148 <link linkend="GlobalProperty">GlobalProperty</link>参照)
150 これら全てのオプション引数を同時に指定することが可能です.
153 <literal>y</literal> がベクトルの場合, plot(y) はベクトル <literal>y</literal>
154 をベクトル <literal>1:size(y,'*')</literal>に対してプロットします.
157 <literal>y</literal>が行列の場合, plot(y) は<literal>y</literal>の各列を
158 <literal>1:size(y,1)</literal>に対してプロットします.
161 <literal>x</literal> および <literal>y</literal> がベクトルの場合, plot(x,y) は
162 ベクトル <literal>y</literal> をベクトル <literal>x</literal>に対してプロットします.
163 ベクトル<literal>x</literal> および
164 <literal>y</literal> の要素数は同じである必要があります.
167 <literal>x</literal> がベクトルで <literal>y</literal> が行列の場合, plot(x,y)
168 は <literal>y</literal> の各列をベクトル <literal>x</literal>に対してプロットします.
169 この場合,<literal>y</literal> の列の数は
170 <literal>x</literal> のエントリの数と同じである必要があります.
173 <literal>x</literal> と <literal>y</literal> が行列の場合, plot(x,y) は
174 <literal>y</literal> の各列を<literal>x</literal>の同じ列に対してプロットします.
175 この場合,<literal>x</literal> と<literal>y</literal> の大きさは同じである必要があります.
178 最後に, <literal>x</literal> または <literal>y</literal> が行列の場合,
179 ベクトルは行列の各行または各列に対してプロットされます.
180 この選択は,行列の行また列の次元にベクトルの行または列の次元のどちらが
182 (<literal>x</literal> または <literal>y</literal> のみが)正方行列の場合,
183 列が行よりも優先されます(以下の例参照).
188 <literal>plot</literal> は,
190 <literal>x</literal> および <literal>y</literal>を転置し,警告を出力します.
192 <literal>x</literal> が<literal>y</literal>の列と同じ行数を有する場合.
193 <literal>y</literal> が正方の場合, 転置は行われません.
197 <literal>y</literal> はマクロまたはプリミティブとして定義された関数と
199 <literal>x</literal> データを(ベクトルまたは行列として)指定する必要があり,
200 対応する<literal>y(x)</literal>の計算が暗黙の内に行われます.
203 <literal>LineSpec</literal> と<literal>GlobalProperty</literal> 引数は
204 プロットをカスタマイズするために使用されます.
205 以下に利用可能な全オプションのリストを示します.
209 <term>LineSpec</term>
211 <para>このオプションは曲線の描画方法を簡便な方法で
213 このオプションは,LineStyle, Marker および Color指定子を含む文字列とする
216 <para>これらのリファレンスは曖昧さがないように
217 文字列内で指定することが必要です(順番は重要ではありません).
218 例えば,ダイヤモンド型の記号を付けた赤い長い破線を指定する場合,
220 <literal>'r--d'</literal> , <literal>'--dire'</literal> または
221 <literal>'--reddiam'</literal> または他のあいまいでない命令,
222 もしくは全体を指定する <literal>'diamondred--'</literal>
223 (<link linkend="LineSpec">LineSpec</link>参照)
226 線の種類,色,マーカの色(および大きさ)も
227 ポリラインエンティティプロパティにより(再)設定できることに
229 (<link linkend="polyline_properties">polyline_properties</link>参照).
234 <term>GlobalProperty</term>
237 このオプションは, <literal>LineSpec</literal>を使用する
238 よりも多くのオプションを用いて曲線のプロット方法を指定できます.
239 <literal>PropertyName</literal>を定義する文字列と
240 その値である<literal>PropertyValue</literal>
241 (<literal>PropertyName</literal>の型に依存して文字列または整数または...)
243 <literal>GlobalProperty</literal>により複数のプロパティ,
244 つまり, LineSpec により利用可能なあらゆるプロパティ,
245 マーカの色(表示色および背景色), 視認性, クリッピング, 曲線の太さ,
247 (<link linkend="GlobalProperty">GlobalProperty</link>参照)
252 (<link linkend="polyline_properties">polyline_properties</link>参照)
253 により(再)設定できることに注意してください.
259 <refsection role="description">
261 <para>デフォルトでは, 連続したプロットは重ね描きされます.
263 <literal>clf()</literal>を使用してください. <literal>auto_clear</literal> モードを
264 デフォルトで有効にするには,次のようにデフォルトの軸を編集してください:
266 <para>da=gda();</para>
267 <para>da.auto_clear = 'on'</para>
269 表示を改善するために<literal>plot</literal>関数が親の軸の
270 <literal>box</literal>プロパティを修正することがあります.
271 これは,親の軸が<literal>plot</literal>のコールにより作成されたか,
273 軸の一つが原点を中心にしている場合, ボックスは無効となります.
274 その他の場合, ボックスが有効になります.
277 ボックスプロパティと軸の配置に関する詳細については,
278 <link linkend="axes_properties">axes_properties</link>を参照ください.
281 色を指定しない場合,曲線をプロットする際にデフォルトの色テーブルが
283 複数の線を描画する際,plotコマンドは自動的に
287 <informaltable border="1">
289 <th> <literal>R</literal> </th>
290 <th> <literal>G</literal> </th>
291 <th> <literal>B</literal> </th>
293 <tr> <td>0.</td> <td>0.</td> <td>1.</td> </tr>
294 <tr> <td>0.</td> <td>0.5</td> <td>0.</td> </tr>
295 <tr> <td>1.</td> <td>0.</td> <td>0.</td> </tr>
296 <tr> <td>0.</td> <td>0.75</td> <td>0.75</td> </tr>
297 <tr> <td>0.75</td> <td>0.</td> <td>0.75</td> </tr>
298 <tr> <td>0.75</td> <td>0.75</td> <td>0.</td> </tr>
299 <tr> <td>0.25</td> <td>0.25</td> <td>0.25</td> </tr>
303 コマンド <literal>plot</literal> を入力することによりデモを見ることができます.
306 <refsection role="examples">
309 <emphasis role="bold">Choosing the normal or logarithmic plotting mode:</emphasis>
311 <programlisting role="example"><![CDATA[
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;
322 subplot(2,2,1), plot(x, G), title("plot(x, y)")
323 subplot(2,2,2), plot("ln", x, G), title("semilog-x : plot(""ln"", x, y)"); gca().sub_ticks(1) = 8;
324 subplot(2,2,3), plot("nl", x, G), title("semilog-y : plot(""nl"", x, y)"); gca().sub_ticks(2) = 8;
325 subplot(2,2,4), plot("ll", x, G), title("loglog : plot(""ll"", x, y)"); gca().sub_ticks = [8 8];
330 gda().grid = [1 1]*color("grey70");
331 title(gda(), "", "fontsize", 3, "color", "lightseagreen", "fontname", "helvetica bold");
333 x = linspace(1e-1,100,1000);
336 G = exp(-((x-xm)/dx).^2/2)*30;
338 subplot(2,2,1), plot(x, G), title("plot(x, y)")
339 subplot(2,2,2), plot("ln", x, G), title("semilog-x : plot(""ln"", x, y)")
340 gca().sub_ticks(1) = 8;
341 subplot(2,2,3), plot("nl", x, G), title("semilog-y : plot(""nl"", x, y)")
342 gca().sub_ticks(2) = 8;
343 subplot(2,2,4), plot("ll", x, G), title("loglog : plot(""ll"", x, y)")
344 gca().sub_ticks = [8 8];
346 gcf().axes_size = [750 520];
351 <emphasis role="bold">Simple plot of a single curve:</emphasis>
353 <programlisting role="example"><![CDATA[
354 // Default abscissae = indices
356 plot(sin(0:0.1:2*%pi))
359 // With explicit abscissae:
363 xlabel("Specified abscissae")
366 // Default abscissae = indices
368 plot(sin(0:0.1:2*%pi))
371 // With explicit abscissae:
375 xlabel("Specified abscissae")
377 gcf().axes_size = [700 350];
381 <emphasis role="bold">Multiple curves with shared abscissae:</emphasis>
382 Y: 1 column = 1 curve:
384 <programlisting role="example"><![CDATA[
387 plot(x, [sin(x) sin(2*x) sin(3*x)])
391 plot(x,[sin(x) sin(2*x) sin(3*x)])
393 gcf().axes_size = [700 350];
397 <emphasis role="bold">
398 Specifying a macro or a builtin instead of explicit ordinates:
401 <programlisting role="example"><![CDATA[
403 subplot(2,2,1) // sin() is a builtin
404 plot(1:0.1:10, sin) // <=> plot(1:0.1:10, sin(1:0.1:10))
405 title("plot(x, sin)", "fontsize",3)
408 deff('y = myFun(x)','y = x + rand(x)')
410 plot(-3:0.1:5, myFun)
411 title("plot(x, myFun)", "fontsize",3)
413 // With functions with parameters:
415 plot(1:0.05:7, list(delip, -0.4)) // <=> plot(1:0.05:7, delip(1:0.05:7,-0.4) )
416 title("plot(x, list(delip,-0.4))", "fontsize",3)
418 function Y = myPow(x,p)
423 Y(:,i) = Y(:,i)/m(i);
428 plot(x, list(myPow,1:5))
429 title("plot(x, list(myPow,1:5))", "fontsize",3)
431 <scilab:image><![CDATA[
432 subplot(2,2,1) // sin() is a builtin
433 plot(1:0.1:10, sin) // <=> plot(1:0.1:10, sin(1:0.1:10))
434 title("plot(x,sin)", "fontsize",3)
437 deff('y = myFun(x)','y = x + rand(x)')
439 plot(-3:0.1:5, myFun)
440 title("plot(x, myFun)", "fontsize",3)
442 // With functions with parameters:
444 plot(1:0.05:7, list(delip, -0.4)) // <=> plot(1:0.05:7, delip(1:0.05:7,-0.4) )
445 title("plot(x, list(delip,-0.4))", "fontsize",3)
447 function Y = myPow(x,p)
452 Y(:,i) = Y(:,i)/m(i);
457 plot(x, list(myPow,1:5))
458 title("plot(x, list(myPow,1:5))", "fontsize",3)
460 gcf().axes_size = [730 500];
464 <emphasis role="bold">Setting curves simple styles when calling plot():</emphasis>
466 <programlisting role="example"><![CDATA[
468 t = -%pi:%pi/20:2*%pi;
469 // sin() : in Red, with O marks, without line
470 // cos() : in Green, with + marks, with a solid line
471 // gaussian: in Blue, without marks, with dotted line
472 gauss = 1.5*exp(-(t/2-1).^2)-1;
474 plot(t,sin,'ro', t,cos,'g+-', t,gauss,':b')
476 <scilab:image><![CDATA[
477 t = -%pi:%pi/20:2*%pi;
478 // sin() : in Red, with O marks, without line
479 // cos() : in Green, with + marks, with a solid line
480 // gaussian: in Blue, without marks, with dotted line
481 gauss = 1.5*exp(-(t/2-1).^2)-1;
483 plot(t,sin,'ro', t,cos,'g+-', t,gauss,':b')
485 gcf().axes_size = [800 400];
490 Vertical segments between two curves, with automatic colors, and using Global properties
491 for markers styles. Targeting a defined axes.
493 <programlisting role="example"><![CDATA[
496 ax3 = gca(); // We will draw here later
497 xsetech([0 0 0.7 1]) // Defines the first Axes area
499 // Tuning markers properties
500 plot([t ;t],[sin(t) ;cos(t)],'marker','d','markerFaceColor','green','markerEdgeColor','yel')
502 // Targeting a defined axes
505 <scilab:image><![CDATA[
508 ax3 = gca(); // We will draw here later
509 xsetech([0 0 0.7 1]) // Defines the first Axes area
511 // Tuning markers properties
512 plot([t ;t],[sin(t) ;cos(t)],'marker','d','markerFaceColor','green','markerEdgeColor','yel')
514 // Targeting a defined axes
517 gcf().axes_size = [800 400];
523 <emphasis role="bold">Case of a non-square Y matrix:</emphasis>
524 When it is consistent and required, X or/and Y data are
525 automatically transposed in order to become plottable.
527 <programlisting role="example"><![CDATA[
535 // Only one matching possibility case: how to make 4 identical plots in 4 manners...
536 // x is 1x4 (vector) and y is 4x5 (non square matrix)
537 subplot(221); plot(x', y , "o-"); // OK as is
538 subplot(222); plot(x , y , "o-"); // x is transposed
539 subplot(223); plot(x', y', "o-"); // y is transposed
540 subplot(224); plot(x , y', "o-"); // x and y are transposed
549 // Only one matching possibility case: how to make 4 identical plots in 4 manners...
550 // x is 1x4 (vector) and y is 4x5 (non square matrix)
551 subplot(221); plot(x', y , "o-"); // OK as is
552 subplot(222); plot(x , y , "o-"); // x is transposed
553 subplot(223); plot(x', y', "o-"); // y is transposed
554 subplot(224); plot(x , y', "o-"); // x and y are transposed
557 <emphasis role="bold">Case of a square Y matrix, and X implicit or square:</emphasis>
559 <programlisting role="example"><![CDATA[
566 subplot(231), plot(t,"o-") , title("plot(t)", "fontsize",3)
567 subplot(234), plot(t',"o-"), title("plot(t'')", "fontsize",3)
569 subplot(232), plot(t,t,"o-") , title("plot(t, t)", "fontsize",3)
570 subplot(233), plot(t,t',"o-"), title("plot(t,t'')", "fontsize",3)
572 subplot(235), plot(t', t,"o-"), title("plot(t'', t)", "fontsize",3)
573 subplot(236), plot(t', t',"o-"), title("plot(t'', t'')", "fontsize",3)
575 for i=1:6, gcf().children(i).data_bounds([1 3]) = 0.5; end
584 subplot(231), plot(t,"o-") , title("plot(t)", "fontsize",3)
585 subplot(234), plot(t',"o-"), title("plot(t'')", "fontsize",3)
587 subplot(232), plot(t,t,"o-") , title("plot(t, t)", "fontsize",3)
588 subplot(233), plot(t,t',"o-"), title("plot(t,t'')", "fontsize",3)
590 subplot(235), plot(t', t,"o-"), title("plot(t'', t)", "fontsize",3)
591 subplot(236), plot(t', t',"o-"), title("plot(t'', t'')", "fontsize",3)
593 for i=1:6, gcf().children(i).data_bounds([1 3]) = 0.5; end
595 gcf().axes_size = [800 450];
599 <emphasis role="bold">Special cases of a matrix X and a vector Y:</emphasis>
601 <programlisting role="example"><![CDATA[
609 subplot(221), plot(X, y, "o-"), title("plot(X, row)", "fontsize",3)
610 // equivalent to plot(t, [1 1 1 1; 2 2 2 2; 3 3 3 3; 4 4 4 4])
611 subplot(223), plot(X, y', "o-"), title("plot(X, col) (row = col'')", "fontsize",3)
612 subplot(222), plot(X',y, "o-"), title("plot(X'', row)", "fontsize",3)
613 subplot(224), plot(X',y', "o-"), title("plot(X'', col) (row = col'')", "fontsize",3)
615 for i = 1:4, gcf().children(i).data_bounds([1 3]) = 0.5; end
625 subplot(221), plot(X, y, "o-"), title("plot(X, row)", "fontsize",3)
626 // equivalent to plot(t, [1 1 1 1; 2 2 2 2; 3 3 3 3; 4 4 4 4])
627 subplot(223), plot(X, y', "o-"), title("plot(X, col) (row = col'')", "fontsize",3)
628 subplot(222), plot(X',y, "o-"), title("plot(X'', row)", "fontsize",3)
629 subplot(224), plot(X',y', "o-"), title("plot(X'', col) (row = col'')", "fontsize",3)
631 for i = 1:4, gcf().children(i).data_bounds([1 3]) = 0.5; end
636 <emphasis role="bold">Post-tuning Axes and curves:</emphasis>
638 <programlisting role="example"><![CDATA[
640 plot(x-4,sin(x),x+2,cos(x))
643 a=gca(); // 軸エンティティのハンドル
644 a.x_location = "origin";
645 a.y_location = "origin";
648 // plotにより作成されたエンティティに複数の処理を行う
649 a.children // 軸の子のリスト : ここでは,2個のエンティティの複合子オブジェクト
650 poly1= a.children.children(2); //線分群のハンドルをpoly1 に保存
651 poly1.foreground = 4; // スタイルを変更する別の方法...
652 poly1.thickness = 3; // ...曲線の太さ.
653 poly1.clip_state='off' // 制御をクリップ
658 plot(x-4,sin(x),x+2,cos(x))
660 a.x_location = "origin";
661 a.y_location = "origin";
664 poly1 = a.children.children(2);
665 poly1.foreground = 4;
667 poly1.clip_state='off'
671 <refsection role="see also">
673 <simplelist type="inline">
675 <link linkend="plot2d">plot2d</link>
678 <link linkend="plot2d2">plot2d2</link>
681 <link linkend="plot2d3">plot2d3</link>
684 <link linkend="plot2d4">plot2d4</link>
687 <link linkend="param3d">param3d</link>
690 <link linkend="surf">surf</link>
693 <link linkend="scf">scf</link>
696 <link linkend="clf">clf</link>
699 <link linkend="xdel">xdel</link>
702 <link linkend="delete">delete</link>
705 <link linkend="LineSpec">LineSpec</link>
708 <link linkend="color_list">Named colors</link>
711 <link linkend="GlobalProperty">GlobalProperty</link>
715 <refsection role="history">
719 <revnumber>6.0.1</revnumber>
721 The "color"|"foreground", "markForeground", and "markBackground" GlobalProperty
722 colors can now be chosen among the full predefined colors list, or by
723 their "#RRGGBB" hexadecimal codes, or by their indices in the colormap.
727 <revnumber>6.0.2</revnumber>
729 Plotting a function fun(x, params) with input parameters is now possible with
730 plot(x, list(fun, params)).
734 <revnumber>6.1.0</revnumber>
736 logflag option added.