How do I switch x axis by y axis without using 'view'?
3 次查看(过去 30 天)
显示 更早的评论
Hello,
I'd like to know how can I switch the x axis by y axis without using view ([90 -90]). The view solves my problem, but it doesn't work when I try to add the curves to the histogram.
I need the date in x-axis.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/562856/image.jpeg)
Here's the code.
T = readtable('data1.csv');
dd=T{:,1}; %date (dd/mm/yyyy)
mag=T{:,6};
T_MC = readtable('data2.csv');
dd_MC = t_MC{:,1};
mag_MC = t_MC{:,3};
%Cumulative rate
figure
plot(dd,'b')
hold on
plot(dd_MC,'r')
title('Cumulative Rate')
legend('full', 'full (M >= 1.4)')
%view([90 -90])
hold off
%Histogram
figure
nbins = 192
histogram(dd, nbins, 'facecolor','b')
hold on
histogram(dd_MC, nbins, 'facecolor','r')
xlabel('Date binned by month')
ylabel('N of events')
ylim ([0 80])
yyaxis right
plot(dd,'b')
%view([90 -90])
hold off
Thanks!!
0 个评论
采纳的回答
Cris LaPierre
2021-3-25
Specify your x values as your y values, and vice versa
plot(dd,1:length(dd),'b')
hold on
plot(dd_MC,1:length(dd_MC),'r')
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!