How do I switch x axis by y axis without using 'view'?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
ANA DIAS
am 25 Mär. 2021
Kommentiert: ANA DIAS
am 26 Mär. 2021
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 Kommentare
Akzeptierte Antwort
Cris LaPierre
am 25 Mär. 2021
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')
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Annotations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!