How to plot this graph?
Show older comments
Hi everyone, Can anybody show me how to plot this graph on Matlab? It looks like many subplot in a same row, separately, but I can't find any document in the internet
Thanks

Accepted Answer
More Answers (1)
Either create multiple x-axes at the right positions without the associated y-axes displayed or, perhaps easier, add an offset of the cumulative maximum of axis to left plus an offset to the x-values of each of the 2nd and higher groups of data.
That is, for the second group plot x+80 in lieu of x, (which looks like would be about 110 in plot units) then set 'xtick' and '_xticklabel_' to the desired positions and labels. The overall xlim will be from roughly [-10 450] it looks like guesstimating quickly.
ADDENDUM:
Here's at least one start towards using multiple axes --
H=axes('position',[.13 .11 .7744 .815],'xtick',[],'ytick',[]);
for i=1:4,h(i)=subplot(1,4,i);end
set(h(2:4),'ycolor',[1 1 1],'ytick',[])
set(h(1),'xlim',[-10 80],'xtick',[0 30 50 80])
set(h(2),'xlim',[30 80],'xtick',[30 50 80])
You should get the drift...need to set background for H to fill in the gaps between the various subplots, finish setting their limits and then you can plot your data into them...
ADDENDUM 2:
While I don't have time at the moment to actually 'spearmint, came to me that the way to deal w/ the space between the axes isn't by the underlying axes but by setting up the position and width of the four subplots such that they precisely fill the area. To do this in words would be--
- Set the four via subplot() to default positions,
- Retrieve left position of first and right of last (which is the left+width entries from the position vector for it)
- find new width as (End-Start)/4 from above and
- Set new position to [start,bottom,newwidth,height] where each start_i is start_i-1+width
Then you make the spacing between x axis marks as above with an offset from the initial tick position. Shouldn't be too bad...
4 Comments
Joseph Cheng
on 29 Mar 2014
So basically what i show down in my answer.
dpb
on 29 Mar 2014
Yes, 6 minutes later... :)
I played with subplot solution a little more and while it seems the better at first, it runs into "issues"--the most irritating of which that I don't think there's a way to solve is that the axes object insists on showing tick marks on the RH axis if they're used on the left. So, one ends up w/ a set of seemingly random little lines in the dead area between the first two subplots. One can get rid of them by manually drawing the ticks but then there's little advantage at all of the subplots--so, I'm to the point of using an offset on the x-values for the various points and manipulating the tick labels for a single axis as better/easier in the end.
Joseph Cheng
on 31 Mar 2014
To get rid of the ticks i use the trick of setting the y ticks to
set(h2,'Ytick',[])
but it looks like i forgot to include that and setting the line color to white.
That looks ok if you just do subplot and/or axes but as soon as you plot something onto that axis then it insists on showing the tick marks on the RH axis as well. So what shows up where the LH subplot-2 axes are are also the RH tick marks from subplot-1 that are on because of needing to use the LH axis ticks for it.
Just thought of another workaround, though...
>> for i=1:5,h(i)=subplot(1,5,i);p(i,:)=get(h(i),'position');end
>> p(1,3)=0;set(h(1),'position',p(1,:))
Error using set
Width and height must be > 0
>>
Well, that didn't work, but
>> p(1,3)=0.001;set(h(1),'position',p(1,:))
does to just show the left axis. Now redistribute 2:5 across the range and use first for y-axis only. Then can turn the ytick off on all and not have the annoying RH axis tick that there's no way to turn off afaik once you plot onto the axis if you use ticks at all.
Categories
Find more on Axis Labels in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!