Borrar filtros
Borrar filtros

How do I switch x axis by y axis without using 'view'?

3 visualizaciones (últimos 30 días)
ANA DIAS
ANA DIAS el 25 de Mzo. de 2021
Comentada: ANA DIAS el 26 de Mzo. de 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.
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!!

Respuesta aceptada

Cris LaPierre
Cris LaPierre el 25 de Mzo. de 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')

Más respuestas (0)

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by