How to create a graph with 3 y axis
이전 댓글 표시
Hello,
I been trying to create a graph with 3 y axis and centralise the zero in the middel.
figure
yyaxis left
quiver(EC_time', zeros(size(x_velocity)),x_velocity,y_velocity);
ylim([-0.05 0.05])
axis equal
datetick('x')
axis equal
yyaxis right
bar(EC_time, Mayflux);
ylim([-40 40]);
axis equal
hold on
plot(EC_time, oxygen_may1, 'o-');
hold all
plot(EC_time, oxygen_may1, 'ro-');
plot(EC_time, oxygen_may_optode1, 'go-');
ylim([245 248]);
Could some one give me advise on this? I was trying addaxis but it was not working.
figure
plot(advN.harmonic_fit.thf, Umagadvh)
addaxis(EC_time, Mayflux)
% hold on
addaxis(advN.harmonic_fit.thf, udiradvh);
addaxis(EC_time, oxygen_may1, 'ro-')
datetick 'x'
Thank you.
댓글 수: 14
dpb
2019년 1월 27일
What, specifically, do you think isn't what you want? And what would you want instead?
Rebecca Ellis
2019년 1월 27일
편집: Rebecca Ellis
2019년 1월 27일
K>> which addaxis
'addaxis' not found.
K>>
?? is addaxis??
You can do whatever you want with any axis handle from position to whatever...it matters not how it was actually created.
As an aside not terribly related to the number/placement of axes, I'd recommend switch your time data to datetime and the axes are aware and can dispense with datetick -- unless you've found another subset of specialty graphs TMW hasn't yet updated. In that case, submit bug reports to get them in the "todo" database
Rebecca Ellis
2019년 1월 27일
Looks like from your comment you misspelled the 'ColorOrder' property by having an extra trailing 'er'.
I would guess Oliver Ferdinand's patch is highly important in general, too.
(Somebody really ought to post a patched version instead of leaving this as is, btw!)
It appears the user interface isn't such that the function returns the axes handle(s) directly; the comments indicate they were stuffed into 'UserData' of the original axis object and you've got to go spelunking therein to find them.
Or, if you add just one at a time, you should be able to retrieve it for the newest one as
hAxNew=gca; % retrieve lastest axes created/presumes addaxes leaves current
keeping this as an array of handles if you add more than one, of course, so you don't overwrite the previous.
With that handle, you can do anything to that axes you desire including using it as the target into which to plot with any plotting function that recognizes an axes handle as the target axes, or, if it's a function that doesn't, making it the current axes presuming the function plots into current axes.
If it's one of the real specialty plots, some of them have hardcoded figure or the like that forcefully creates a new axes "no matter what!".
Rebecca Ellis
2019년 1월 27일
dpb
2019년 1월 27일
What's "the yellow data"??? I see nothing about yellow anywheres in sight...
Rebecca Ellis
2019년 1월 28일
dpb
2019년 1월 28일
So, which data are those? Presumably "Mayflux"? since the other styles seem accounted for...well, the yellow axes limits are [-30 0] and Matlab always uses increasing values upwards on axis by default so it's what it really is. If you want that axis to be reversed, then you have to do what you want to it by setting its properties as desired -- the discussion above on either retrieving the handle(s) of the axes objects created by addaxis to use now or later (best practice) or by doing whatever it is that is wanted to that axis while it is still gca (more risky because focus can be changed by user intervention or other actions).
See doc axes for all the properties of axes objects to adjust as desired...what you're probably looking for here is 'yDir' and possibly 'XAxisLocation'
Rebecca Ellis
2019년 1월 28일
편집: Rebecca Ellis
2019년 1월 28일
dpb
2019년 1월 29일
If you'll look at the code for addaxis (and the documentation) you'll see it has plot hardcoded into it so that's all it will do on its own.
As said, however, I'm virtually positive you could "fool mother addaxis" by simply passing NaN to it as the data to create the additional axes if you like where it is placed; and then call whatever plotting routines you wish using that axes handle (which you can either retrieve from the user data where the author squirreled it away or by gca after the call).
dpb
2019년 1월 29일
I don't have the time to spare to try to patch addaxis, but if you'll attach a .fig file with the 3-axis attempt (again presuming you like where the axis, just not the plot), I'll try to take a look at retrieving the axes handle and should be able to do what you want onto that axis ignoring addaxis from that point on.
Or, of course, you could edit it to eliminate the hardcoded plot and pass a plotting function handle--that may have "issues" with all the callback stuff that the author built into it. It appears written for a very specific subset of multiple axes plotting.
A search on File Exchange for "multiple y axes" returned a number of hits besides addaxis I've used none of them but it looks like https://www.mathworks.com/matlabcentral/fileexchange/4425-ploty4-m might be almost trivial to modify to simply add a third axis and replace the plot function hardcoded into all of these submissions with your specific other type plots...or at least show you the basics of generating axes of given size/position.
Rebecca Ellis
2019년 1월 29일
dpb
2019년 1월 29일
I've got pressing deadlines to take too much time away from at present to invest a great deal of time at this instant, sorry...
I'd again make two suggestions--
1) Convert your time data to datetime from the deprecated datenum and you may just find that things work better as there is an overloaded plot function that will automagically get called and you can get rid of datetick
2) If that doesn't bring joy, download and look at the other FEX submission link I showed and see if its application of the third axis will give you a set of axes that you can live. It's much less complicated a solution and you should be able to modify it at will.
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Discrete Data Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!