Step 1.: Creating 2D Graphs

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Creating 2D Graphs

To Plot Sets of Data as Scatter Plots

In Mathcad, data sets may be stored in Data Tables, vectors, or matrices.


(See Handling Data and Vectors and Matrices for more information.)
Once your data is defined in the worksheet, plotting is very easy.

Step 1. Define your data sets 1  7 


or import them:    
2 5
x    y   
3  3 
   
4  6 

Step 2. Create an X-Y Plot by choosing Graph > X-Y Plot from the
Insert menu. Alternatively, click the X-Y Plot button on the Graph toolbar:

Step 3. You see a blank graph with two empty placeholders. Enter your
data set names in the appropriate axis placeholders (in this example, x is on
the x-axis and y is on the y-axis). Then click outside the graph or press
[Enter] to finish.

01.Histograme.xmcdz 1 4/17/2020
7

y 5

3
1 2 3 4
x
By default, Mathcad plots the data as a line and then sets the axis limits
from the minimum to the maximum of the x-axis data.

Step 4. To display a scatter plot, double-click on the graph region. On the


Traces page, click under Type to select "points" and under Symbol, choose
a symbol. Click OK.

y 4

0 1 2 3 4 5
x

01.Histograme.xmcdz 2 4/17/2020
Step 5. To change the axis limits, click on the graph and enter new values at
the ends of each axis.

10

6
y
4

0 2 4 6 8 10
x

To Create a Histogram
There are three steps to creating a histogram plot of a set of
one-dimensional data:
1. Enter or import the data in your worksheet.
2. Use the built-in histogram function to "bin" the data.
3. Plot the results returned by the histogram function.

Step 1. Enter the data in a Data Table or a vector.

Step 2. Define a variable and insert the histogram function by choosing


Function from the Insert menu and selecting "histogram" from the list.
Then, fill in the arguments to the histogram function with the number of
intervals you want and the name of the data.

01.Histograme.xmcdz 3 4/17/2020
2 
 
3 
4 
 
8 
5 
data    H  histogram ( 3 data)
6 
Sort the data into three bins to
9 
get three bars on the plot.
 
1 
2 
 
8 

You can view the results of calling the histogram function by typing, in
this case, H [=].

Interpreting Results from the Histogram Function:

 2.333 4  4 data points in the first interval, with a midpoint of 2.333.

H  5 3 3 data points in the second interval,with a midpoint of 5.


 7.667 3 
  3 data points in the third interval, with a midpoint of 7.667.

Step 3. Insert an X-Y Plot by choosing Graph > X-Y Plot from the Insert
menu. Then, in the x-axis enter the first column of the histogram result and in
the y-axis enter the second column of the result.

By default, Mathcad plots the data as a line, however, histograms are


typically done as bar graphs

01.Histograme.xmcdz 4 4/17/2020
4
Hint: Type [Ctrl] 6
to get the  or
3.8 column placeholder.

3.6
1 Note: Arrays and
H
Data Tables are
3.4
indexed starting at
0 by default.
3.2

3
2 4 6 8
0
H

Step 4. To display a solid bar plot, double-click the graph. On the Traces
page, select "solidbar" under Type. Click OK.

3.8
Note: Click on the graph to
see the axis limits. Note that
3.6 all the data is not visible for
1
H the second two histogram
3.4 bars. The lower-limit of
y-axis data is the minimum
number of points in an
3.2
interval, so a bar is not
visible, just a line.
3
2 4 6 8
0
H

Mathcad sets the axis limits from the minimum to the maximum of the x-axis
data. So we need to change the limits of both the x and y axes to make this
graph meaningful.

01.Histograme.xmcdz 5 4/17/2020
Step 5. To change the axis limits so you can see all the data on the graph,
click on the graph and enter new values at the ends of each axis.

Click on the graph to


3
1 set new axis limits
H
2

0 5 10
0
H

01.Histograme.xmcdz 6 4/17/2020

You might also like