Fplot Octave
The functions grid and box may also be used to add grid and border lines to the plot. By default, the grid is off and the border lines are on. Finally, arrows, text and rectangular or elliptic boxes can be added to highlight parts of a plot using the annotation function. By default, Octave refreshes the plot window when a prompt is printed, or when waiting for input. The drawnow function is used to cause a plot window to be updated. — Built-in Function: drawnow.
Next: Two-dimensional Geometric Shapes, Previous: Axis Configuration, Up: Two-Dimensional Plots [Contents][Index]
- Fplot uses adaptive step control to produce a representative graph, concentrating its evaluation in regions where the function's rate of change is the greatest. Examples Plot the hyperbolic tangent function from -2.
- : plotyy (x1, y1, x2, y2): plotyy (, fun): plotyy (, fun1, fun2): plotyy (hax, ): ax, h1, h2 = plotyy Plot two sets of data with independent y-axes and a common x-axis. The arguments x1 and y1 define the arguments for the first plot and x1 and y2 for the second. By default the arguments are evaluated with feval (@plot, x, y).However the type of plot can be modified with the.
- Re-evaluation on Zoom. When you zoom into a plot, fplot re-evaluates the plot automatically. This re-evaluation on zoom reveals hidden detail at smaller scales. Plot x^3.sin(1/x) for -2 fplot reveals smaller-scale detail. Repeat the zoom 6 times to view smaller-scale.
15.2.1.2 Two-dimensional Function Plotting
Octave can plot a function from a function handle, inline function, orstring defining the function without the user needing to explicitlycreate the data to be plotted. The function fplot
also generatestwo-dimensional plots with linear axes using a function name and limitsfor the range of the x-coordinate instead of the x and y data. Forexample,
produces a plot that is equivalent to the one above, but also includes alegend displaying the name of the plotted function.
Plot a function fn within the range defined by limits.
fn is a function handle, inline function, or string containing thename of the function to evaluate.
The limits of the plot are of the form [xlo, xhi]
or[xlo, xhi, ylo, yhi]
.
The next three arguments are all optional and any number of them may begiven in any order.
tol is the relative tolerance to use for the plot and defaultsto 2e-3 (.2%).
n is the minimum number of points to use. When n is specified,the maximum stepsize will be xhi - xlo / n
. Morethan n points may still be used in order to meet the relativetolerance requirement.
The fmt argument specifies the linestyle to be used by the plotcommand.
If the first argument hax is an axes handle, then plot into this axis,rather than the current axes returned by gca
.
With no output arguments the results are immediately plotted. With twooutput arguments the 2-D plot data is returned. The data can subsequentlybe plotted manually with plot (x, y)
.
Example:
Programming Notes:
fplot
works best with continuous functions. Functions withdiscontinuities are unlikely to plot well. This restriction may be removedin the future.
fplot
requires that the function accept and return a vector argument.Consider this when writing user-defined functions and use .*
,./
, etc. See the function vectorize
for potentiallyconverting inline or anonymous functions to vectorized versions.
See also:ezplot, plot, vectorize.
Other functions that can create two-dimensional plots directly from afunction include ezplot
, ezcontour
, ezcontourf
andezpolar
.
Plot the 2-D curve defined by the function f.
The function f may be a string, inline function, or function handleand can have either one or two variables. If f has one variable, thenthe function is plotted over the domain -2*pi < x < 2*pi
with 500 points.
If f2v is a function of two variables then the implicit functionf(x,y) = 0
is calculated over the meshed domain-2*pi <= x y <= 2*pi
with 60 points in each dimension.
For example:
If two functions are passed as inputs then the parametric function
is plotted over the domain -2*pi <= t <= 2*pi
with 500 points.
If dom is a two element vector, it represents the minimum and maximumvalues of both x and y, or t for a parametric plot. Ifdom is a four element vector, then the minimum and maximum values are[xmin xmax ymin ymax]
.
n is a scalar defining the number of points to use in plottingthe function.
If the first argument hax is an axes handle, then plot into this axis,rather than the current axes returned by gca
.
The optional return value h is a vector of graphics handles tothe created line objects.
See also:plot, ezplot3, ezpolar, ezcontour, ezcontourf, ezmesh, ezmeshc, ezsurf, ezsurfc.
Contour Plot Octave
Plot the contour lines of a function.
f is a string, inline function, or function handle with two argumentsdefining the function. By default the plot is over the meshed domain-2*pi <= x y <= 2*pi
with 60 points in each dimension.
If dom is a two element vector, it represents the minimum and maximumvalues of both x and y. If dom is a four element vector,then the minimum and maximum values are [xmin xmax ymin ymax]
.
n is a scalar defining the number of points to use in each dimension.
If the first argument hax is an axes handle, then plot into this axis,rather than the current axes returned by gca
.
The optional return value h is a graphics handle to the created plot.
Example:
See also:contour, ezcontourf, ezplot, ezmeshc, ezsurfc.
Plot the filled contour lines of a function.
f is a string, inline function, or function handle with two argumentsdefining the function. By default the plot is over the meshed domain-2*pi <= x y <= 2*pi
with 60 points in each dimension.
If dom is a two element vector, it represents the minimum and maximumvalues of both x and y. If dom is a four element vector,then the minimum and maximum values are [xmin xmax ymin ymax]
.
n is a scalar defining the number of points to use in each dimension.
If the first argument hax is an axes handle, then plot into this axis,rather than the current axes returned by gca
.
The optional return value h is a graphics handle to the created plot.
Plot Octave
Example:
See also:contourf, ezcontour, ezplot, ezmeshc, ezsurfc.
Plot a 2-D function in polar coordinates.
The function f is a string, inline function, or function handle witha single argument. The expected form of the function isrho = f(theta)
.By default the plot is over the domain 0 <= theta <= 2*pi
with 500 points.
If dom is a two element vector, it represents the minimum and maximumvalues of theta.
n is a scalar defining the number of points to use in plottingthe function.
If the first argument hax is an axes handle, then plot into this axis,rather than the current axes returned by gca
.
The optional return value h is a graphics handle to the created plot.
Example:
Scatter Plot Octave
See also:polar, ezplot.
Parametric Plot Octave
Next: Two-dimensional Geometric Shapes, Previous: Axis Configuration, Up: Two-Dimensional Plots [Contents][Index]
Fplot Help Octave
> --- On Tue, 2013/7/16, martine1212 wrote:
>
>> According to the help menu...
>>
>> — Function File: print ()
>> — Function File: print (options)
>> — Function File: print (filename, options)
>> — Function File: print (h, filename, options)
>>
>> Using the last one in my program
>>
>> print(H1, 'dummy.pdf', -landscape);
>>
>> print (h1, 'dummy.pdf', -landscape)
>> ?? error?? landscape
>> error: `landscape' undefined near line 69 column 26
>> error: evaluating argument list element number 3
>>
>> ok try putting '-landscape'
>>
>> print (h1, 'dummy.pdf', '-landscape')
>> error: strtrim: S argument must be a string or cellstring
>> error: called from:
>> error: /usr/share/octave/3.6.3/m/strings/strtrim.m at line 71, column 5
>> error: /usr/share/octave/3.6.3/m/plot/private/__print_parse_opts__.m at
>> line 78, column 9
>> error: /usr/share/octave/3.6.3/m/plot/print.m at line 260, column 8
>>
>> ok, how does it work??
>>
>> This works (but it does not follow the published format)
>>
>> print -landscape dummy.pdf
>>
>> but how do I tell to print h1
>>
>
> The below worked for me (octave 3.6.4 MSVC)
>
> figure(2);
> fplot ('sin', [0, 2*pi]);
> print(2, 'dummy.pdf', '-landscape');
>