×

Let's log you in.

or

Don't have a StudySoup account? Create one here!

×

Create a StudySoup account

Be part of our community, it's free to join!

or

By creating an account you agree to StudySoup's terms and conditions and privacy policy

Already have a StudySoup account? Login here

by: Ana Beyer

3

0

7

Engr101 - Week 5 - Lecture 8 Engr 101

Marketplace > University of Michigan > Engineering > Engr 101 > Engr101 Week 5 Lecture 8
Ana Beyer
UM

Get a free preview of these Notes, just enter your email below.

×
Unlock Preview

Why put in your email? Get access to more of this material and other relevant free materials for your school

These notes cover everything about plotting. Specifically, topics such as labeling axes and graphs, working with different figures, plotting multiple data sets, and graphing pie and bar graphs.
COURSE
Introduction to Computer Programming
PROF.
Laura Alford
TYPE
Class Notes
PAGES
7
WORDS
CONCEPTS
Engr101, Matlab, ComputerProgamming, Plotting, BarGraphs, PieCharts, LabelingAxes, MultipleDataSets
KARMA
25 ?

Popular in Engineering

This 7 page Class Notes was uploaded by Ana Beyer on Tuesday October 4, 2016. The Class Notes belongs to Engr 101 at University of Michigan taught by Laura Alford in Fall 2016. Since its upload, it has received 3 views. For similar materials see Introduction to Computer Programming in Engineering at University of Michigan.

×

Reviews for Engr101 - Week 5 - Lecture 8

×

×

What is Karma?

You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!

Date Created: 10/04/16
Lecture 8- Plotting Tuesday, October 4, 2016 12:12 PM Creating Scatterplots Using plot(x, y) function • Uses the scatter(x, y) function • • It takes two arguments which are interpreted as x and y coordinates • Plotting Functions • plot requires a set of ordered pairs Plotting Multiple Sets of Data ○ Ex: you can't do plot(sin) • Plot and scatter can work w/ multiple sets of data • To create a smoother plot, just use more data points by decreasing the step size • Ex: linspace Function • Another way to change the step size of a range The above example will graph x, sin(x) and x, cos(x) and x, cos(x.^2) together all on one • Format: linspace( start , end, amt of #'s ) • Ex: Figures • Figures are used to display graphics • The current figure (initially Figure 1), is where the new figure will be displayed every time you run a script • If a figure isn't open, a new figure will open and that becomes the current figure • The figure function manages all your figures • To create a new figure simply type figure( ); • figure(n); sets figure n to be the current figure and then you can specifically work with/change that figure Lecture 8- Plotting Tuesday, October 4, 2016 12:12 PM Creating Scatterplots Using plot(x, y) function • Uses the scatter(x, y) function • • It takes two arguments which are interpreted as x and y coordinates • Plotting Functions • plot requires a set of ordered pairs Plotting Multiple Sets of Data ○ Ex: you can't do plot(sin) • Plot and scatter can work w/ multiple sets of data • To create a smoother plot, just use more data points by decreasing the step size • Ex: linspace Function • Another way to change the step size of a range The above example will graph x, sin(x) and x, cos(x) and x, cos(x.^2) together all on one • Format: linspace( start , end, amt of #'s ) • Ex: Figures • Figures are used to display graphics • The current figure (initially Figure 1), is where the new figure will be displayed every time you run a script • If a figure isn't open, a new figure will open and that becomes the current figure • The figure function manages all your figures • To create a new figure simply type figure( ); • figure(n); sets figure n to be the current figure and then you can specifically work with/change that figure • figure(n); sets figure n to be the current figure and then you can specifically work with/change that figure The above example shows 2 equivalent ways of establishing a range Closing Figures Multiple Plots in One Figure • You need to use the hold function • hold on allows you to keep the plots that follow all in one figure instead of overwriting them (which is the default setting) • hold off will now turn this off so that new plots will once again overwrite old ones Creating a Bar Graph • bar function ○ barh will create a horizontal bar graph ○ bar3 will create a 3D bar graph • Format: bar ( labels & bar positions , amt for each bar ) Creating a Pie Chart • Requires the pie function ○ pie3 creates a 3D pie chart Grouped Bar Graphs • Format: pie( vector containing data , labels for each category ) • Vectors containing words require curly brackets { } instead of square brackets [ ] and each set of words requires its ownsingle quotations ' ' Title, Axes Labels, Legends • title( 'Nameof graph' ) • Axes: • figure(n); sets figure n to be the current figure and then you can specifically work with/change that figure The above example shows 2 equivalent ways of establishing a range Closing Figures Multiple Plots in One Figure • You need to use the hold function • hold on allows you to keep the plots that follow all in one figure instead of overwriting them (which is the default setting) • hold off will now turn this off so that new plots will once again overwrite old ones Creating a Bar Graph • bar function ○ barh will create a horizontal bar graph ○ bar3 will create a 3D bar graph • Format: bar ( labels & bar positions , amt for each bar ) Creating a Pie Chart • Requires the pie function ○ pie3 creates a 3D pie chart Grouped Bar Graphs • Format: pie( vector containing data , labels for each category ) • Vectors containing words require curly brackets { } instead of square brackets [ ] and each set of words requires its ownsingle quotations ' ' Title, Axes Labels, Legends • title( 'Nameof graph' ) • Axes: Title, Axes Labels, Legends • title( 'Nameof graph' ) • Axes: ○ xlabel( 'Name of x-axis' ) ○ ylabel( 'Name of y-axis' ) • legend( 'Data Set 1' , 'Data Set 2' , 'Location' ) ○ It'll know how many sets of data there are so it'll take the next label as the legend's location ○ For example you can write ' northwest ' as a location You can also do these things directly in the figure itself Customizing Axes • MATLAB automatically creates axes' intervals based on what it thinks will be good for the data set you give it • To change these: Customizing Line Plots • The last input in the plot function will customize the type of line or markers that the graph will use • These need to be put in single quotations ' ' Marker Types Title, Axes Labels, Legends • title( 'Nameof graph' ) • Axes: ○ xlabel( 'Name of x-axis' ) ○ ylabel( 'Name of y-axis' ) • legend( 'Data Set 1' , 'Data Set 2' , 'Location' ) ○ It'll know how many sets of data there are so it'll take the next label as the legend's location ○ For example you can write ' northwest ' as a location You can also do these things directly in the figure itself Customizing Axes • MATLAB automatically creates axes' intervals based on what it thinks will be good for the data set you give it • To change these: Customizing Line Plots • The last input in the plot function will customize the type of line or markers that the graph will use • These need to be put in single quotations ' ' Marker Types

×

×

BOOM! Enjoy Your Free Notes!

×

Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'

Why people love StudySoup

Jim McGreen Ohio University

"Knowing I can count on the Elite Notetaker in my class allows me to focus on what the professor is saying instead of just scribbling notes the whole time and falling behind."

Anthony Lee UC Santa Barbara

"I bought an awesome study guide, which helped me get an A in my Math 34B class this quarter!"

Steve Martinelli UC Los Angeles

Forbes

"Their 'Elite Notetakers' are making over \$1,200/month in sales by creating high quality content that helps their classmates in a time of need."

Become an Elite Notetaker and start selling your notes online!
×

Refund Policy

STUDYSOUP CANCELLATION POLICY

All subscriptions to StudySoup are paid in full at the time of subscribing. To change your credit card information or to cancel your subscription, go to "Edit Settings". All credit card information will be available there. If you should decide to cancel your subscription, it will continue to be valid until the next payment period, as all payments for the current period were made in advance. For special circumstances, please email support@studysoup.com

STUDYSOUP REFUND POLICY

StudySoup has more than 1 million course-specific study resources to help students study smarter. If you’re having trouble finding what you’re looking for, our customer support team can help you find what you need! Feel free to contact them here: support@studysoup.com

Recurring Subscriptions: If you have canceled your recurring subscription on the day of renewal and have not downloaded any documents, you may request a refund by submitting an email to support@studysoup.com

Satisfaction Guarantee: If you’re not satisfied with your subscription, you can contact us for further help. Contact must be made within 3 business days of your subscription purchase and your refund request will be subject for review.

Please Note: Refunds can never be provided more than 30 days after the initial purchase date regardless of your activity on the site.