Add a second x-axis to a given multi-series plot
1 次查看(过去 30 天)
显示 更早的评论
As can be seen in the figure below, the plot command gives us a graph of Sound Power(dB) Vs Frequency for different surfaces. I am required to add a second axis to the below plot such that the x-axis also includes the 'rpm'. I have a vector of 'rpm's' for all the frequencies. rpm and frequency are related. rpm = frequency/(time order*60). Currently my x-axis contains only the frequency. How can I add a second axis(rpm's) without crowding the current x axis(frequency)? Here is the code which I am using..
ord(y1).freq = transpose(ord(y1).dat(1,:));
ord(y1).rpm = ord(y1).freq/ord1(y1)*60;
ord(y1).total_lw = transpose(ord(y1).dat(2,:));
ord(y1).lw = transpose(ord(y1).dat(3,:));
ord(y1).lw2 = transpose(ord(y1).dat(4,:));
ord(y1).lw3 = transpose(ord(y1).dat(5,:));
figure;
% Plot for frequency and sound power
x = ord(y1).freq;
z1 = ord(y1).lw; z2 = ord(y1).lw2; z3 = ord(y1).lw3; z4 = ord(y1).total_lw;
plot(x,z1,x,z2,x,z3,x,z4,'--','Linewidth',1.5);
title(sprintf('%s for the time order %d',Method, ord1(y1)),'FontSize',16,'Fontweight','bold');
grid on
xlabel('Frequency Hz','FontSize',12,'Fontweight','bold');
ylabel('Schallleistung dB','FontSize',12,'Fontweight','bold');
legend('Surface1','Surface2','Surface3','Total Surface','location','southeast');
Thank you in advance!
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/150722/image.png)
0 个评论
采纳的回答
dpb
2015-10-22
See File Exchange AddTXaxis which does precisely what you're asking for altho I note it has an issue w/ new HG2 engine that may need some patches to work around.
Or do a search for plotxx on the FEX; there are quite a number of similar routines. Or, there's the section in the documentation under Line Plots on Using Multiple X- and Y-Axes that outlines the basic process.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Line Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!