0% found this document useful (0 votes)
187 views13 pages

Plotting Octave

This document summarizes the types of graphs that can be created using Octave, including X-Y plots, scatter plots, histograms, contours, polar plots, pie charts, 3D meshes, and more. It provides examples of functions to generate each graph type, such as plot(x,y) to create an X-Y plot or hist(y) to create a histogram. Additional details are given on formatting graph properties, saving graphs as files, and using commands like hold on to control the plotting window.

Uploaded by

Jhonatan Arias
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
187 views13 pages

Plotting Octave

This document summarizes the types of graphs that can be created using Octave, including X-Y plots, scatter plots, histograms, contours, polar plots, pie charts, 3D meshes, and more. It provides examples of functions to generate each graph type, such as plot(x,y) to create an X-Y plot or hist(y) to create a histogram. Additional details are given on formatting graph properties, saving graphs as files, and using commands like hold on to control the plotting window.

Uploaded by

Jhonatan Arias
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 13

Plotting Data

Octave Tutorial #4
Types of Graphs Supported
• X-Y plots
• Scatter plots
• Histogram’s
• Contour
• Polar plots
• Pie Charts
• 3D Meshes
• Many more.
X-Y Plots
• Simple x-y plot y in relation to x
• plot(y) – Plots the vector y with the index as x.
• plot(x,y) – Plots vector y in relation to x vector.
• plot(x,y, fmt) – modifies how the line/points are
drawn. Default is ‘-’ solid line.
• There is also a property, value arguments that can
be used to change certain attributes. Check the
wiki! If you need to use this.
Scatter
• Much like the x-y plot how ever only the points
will be drawn.
• scatter(x,y) – Plots vector y in relation to x
vector.
• scatter(x,y,s) – modifies how big the markers
size is. Default is 8 points.
• You can add the optional argument “filled” to fill
in the markers.
Histogram’s
• Histogram’s are a graph of a count of items in a
matrix or a vector.
• hist(y) – Creates a histogram of the data with 10
bins.
• hist(y, nbins) – Creates a histogram of the data
with nbins number of bins.
Contour
• Contour’s are a cross section of a 3 dimensional
graph parallel to the x,y plane.
• contour(z) – Takes a matrix and makes a contour
of that matrix.
• contour(x,y,z) – if the x & y are the same as used
to make z, the graph will be the same.
Polar plot
• You can also plot data in polar coordinates.
• polar(theta, rho) – draws a polar graph with
each angle theta relating to value rho.
• Fun for drawing circles and spirals.
Pie Charts
• Creates a simple pie chart with a single vector
with each slice being the percentage of the
vector sum.
• pie(x) – creates pie chart of vector x
• pie(x, explode) – creates a pie chart with
optional input explode is a vector of the same
length as x that, if non-zero, "explodes" the slice
from the pie chart.
3D Meshes
• You can draw graphs in 3D space.
• mesh(x,y,z) – Draws a wireframe mesh.
• meshc(x,y,z) – Draws a wireframe mesh with
underlying contour lines.
• meshz(x,y,z) – Draws a wireframe mesh with Z
curtain.
• surf(x,y,z) – Draws a shaded mesh.
Saving Graphs
• You can save graphs as files or even directly
send them to your printer!(Though I
recommend saving to file first)
• print -dpng ‘<filename>.png’
print -djpg ‘<filename>.jpg’
Graph options
• I spoke a little about graph option when talking
about x-y plots. But some more detail:
• Format options: linestyles(‘-’ ‘--’ ‘:’ ‘-.’)
markerstyles(‘+’ ‘o’ ‘*’ ‘.’ ‘x’ ‘s’ ‘d’)
colors(‘k’ ‘r’ ‘g’ ‘b’ ‘m’ ‘c’ ‘w’)
• Attributes: "linestyle", "linewidth", "color", "marker",
"markersize", "markeredgecolor", "markerfacecolor"
Extra’s
• The Octave documents has almost everything you
could need to figure out how to use a graph. Even
some basic examples! (link in description)
• If you don’t get any errors when trying to draw a graph,
use the ‘hold on’ command to refresh the gnuplot
window.
• Using hold on you can plot multiple graphs on the one
image.
• Remember to use ‘close’ to close the graphics window.
Next
• Control Statements

• Feel free to leave any questions in the


comments.

You might also like