Question

I am trying to plot the wake velocity deficient behind an object at different streamwise positions (pos.1, 2 and 3) behind the object.

A rough sketch of how the graph should look like is shown below. The x-axis represents velocity and the y-axis is the coordinate normal to the flow.
enter image description here

How can I restart the x-axis such that the data of each position is plotted in it's own space, resembling it's actual position in the flow.

Was it helpful?

Solution

Easiest solution I think is to create all plots you need in horizontally arranged subplots, and then "beautify" according to your level of perfectionism ^_^

enter image description here

The "beautifications" I did in this case are:

  • For the axes in each subplot, switch the 'box' option off
  • Set the ytick to [] and color the y-axes white, of every y-axis except the leftmost one
  • create another axes object in the background without any axes labels, so that it appears that the subplots are really one plot

Here's the code:

%// Some bogus data
y = 0:0.1:4*pi;

x1 = sin(y);
x2 = sin(3*y);
x3 = sin(2*y).*sin(5*y);

%// Initialize figure window
figure(1), clf, hold on

%// Plot each plot on its own axes
subplot(1,3,3), hold on
plot(x3,y)
set(gca,...
    'ytick' , [],...
    'ycolor', 'w',...
    'box'   , 'off');

subplot(1,3,2)
plot(x2,y)
set(gca,...
    'ytick' , [],...    
    'ycolor', 'w',...
    'box'   , 'off')

subplot(1,3,1)
plot(x1,y)
set(gca,... 
    'box', 'off') %// NOTE: don't kill these axes

%// Background axes
P = axes('parent', 1, 'xtick', [], 'ytick', []);
uistack(P, 'down', 10)

OTHER TIPS

You could consider plotting your data on a single x-axis with an offset and changing the label of the x-axis ticks.

Consider your x-vector to be x_pos1 for the first position, your second and third would be similar but with an addition of an offset. E.g. offset = 15; x_pos2 = x_pos1+offset;

You can obtain and change your x-axis tick label by:

get(gca, 'xticklabel') 
set(gca, 'xticklabel', yourLabelHere)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top