Thoughts on the Engineering Industry

A blog covering engineering, technology and business topics

Matlab Commands for Creating Different Plots

Hello everyone! I hope y’all are doing well.  Today I want to talk about some common plotting commands I use to generate sharp looking plots and save them.  I will keep it to a short length in this post and if there are more that I feel are necessary I will do it another post next weekend.  Along with that, I will do them in order that I use them in most cases.

function – This command is very simple in that it creates a new figure.  This isn’t always needed, but it is good habit to always use this command since it would leave all your figures open that you have created.

subplot(m,n,p)  –  This command allows you to place multiple plots on a single figure.  The m variable specifies the number of rows, the n variable specifies the number of columns, and the p variable specifies the location to place the following plot.  Placement goes from left to right in the top row, then down next row and from left to right, and continues in that pattern.

hold on/off – This command allows you to plot on the same figure and subplot(if used) as the previous plot without replacing the previous plot.  Use hold on to start overlay process and hold off to stop it.

plot(x,y,’a’,’b’) – This command plots a line graph.  x is the matrix that represent the horizontal variable and y is the matrix that represents the vertical variable.  The ‘a’ variable is where the code to define the color is placed.  The b variable is where the code to define the line type is placed.   Go to help plot and all the codes for the color and line type are provided.

bar(x,y) – This command creates a bar graph.  x is the matrix representing the values or labels on the horizontal axis.  y is the matrix representing the values on the vertical axis.  barh(x,y) executes the same command for a horizontal bar graph, bar3(x,y) for a 3-d bar graph, and bar3h(x,y) for a 3-d horizontal bar graph.  I am less familiar with the details of these plot commands, however, the help command should give you some more information.

pie(x) – This command creates of pie chart of the data in matrix x.  This is another command I haven’t used often; like with the bar command, the help command should give the specific details of it.

These are the commands I want to cover for today.  Next Saturday I will continue this topic with commands that can be used to label the plots and specify other details of an individual plot.  Have a good weekend!

Question of the week: Which plotting methods do you prefer?  Subplots, Layered Plots, Individual Plots or a combination of them all?  Are there certain situations you find yourself requiring use of one over another?


Single Post Navigation

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: