Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Plot a data series beneath another one

Tags:

plot

matlab

When you plot things in Matlab, the most recently plotted data series is placed on top of whatever's already there. For example:

figure; hold on
plot(sin(linspace(0,pi)),'linewidth',4,'color',[0 0 1])
plot(cos(linspace(0,pi)),'linewidth',4,'color',[1 0 0])

Here, the red line is shown on top of the blue line (where they intersect). Is there any way to set "how deep" a line is drawn, so that you can plot things beneath what's already there?

like image 693
Will Robertson Avatar asked Oct 16 '08 05:10

Will Robertson


People also ask

How do you plot one series to another in Excel?

Select all the data you want to graph, click the "Insert" tab, and then select the chart type and sub-type you want to plot. The chart should show a separate plot for the first and second data series on a common Y axis.

How do you plot additional data series in a selected chart?

Right-click the chart, and then choose Select Data. The Select Data Source dialog box appears on the worksheet that contains the source data for the chart. Leaving the dialog box open, click in the worksheet, and then click and drag to select all the data you want to use for the chart, including the new data series.


1 Answers

Use the uistack command. For example:

h1 = plot(1:10, 'b');
hold on;
h2 = plot(1:10, 'r');

will plot two lines with the red line plotted on top of the blue line. If you then do:

uistack(h1);

the blue line will be brought to the front.

like image 163
b3. Avatar answered Nov 10 '22 11:11

b3.