Borrar filtros
Borrar filtros

How to plot specific graph scale?

2 visualizaciones (últimos 30 días)
Nur Zawani Rosli
Nur Zawani Rosli el 6 de Abr. de 2023
Respondida: Joe Vinciguerra el 6 de Abr. de 2023
Hello, I have been trying to plot these graphs and I only have the data between the value of 32 to 54. However, it ends up extending the y-axis to 55 and 30 and there's a blank space on the top and bottom of the graphs as shown in the figure below. I also wanted the x-acis to extend to the value of -2 and 2.
Here's an example of the graph plot that I wanted. The line ends up excactly between the latitude of 22 deg to -2 deg on the y-axis and the x-axis extends to -2 to 2. I have tried using xlim and xticks but it doesn't work, how do I solve this problem?
Here's the code that I have been usig to plot.
day_B = xlsread('day_B.xlsx');
N = diff(diff(day_B(:,5)));
E = diff(diff(day_B(:,6)));
C = diff(diff(day_B(:,7)));
lat = day_B(:,2);
lin = linspace(32,54,343);
figure(1)
subplot(1,3,1)
yline(0)
plot(N,lin)
title('N frame')
subplot(1,3,2)
plot(E,lin)
title('E frame')
subplot(1,3,3)
plot(C,lin)
title('C frame')
  2 comentarios
Dyuman Joshi
Dyuman Joshi el 6 de Abr. de 2023
xlim([-2 2])
ylim([32 54])
This doesn't work? Keep in mind that you have to do this for each subplot individually.
Nur Zawani Rosli
Nur Zawani Rosli el 6 de Abr. de 2023
Yes, it works! I didn't put the xlim and ylim at the right place and for each subplot before, my mistake. Thank you!

Iniciar sesión para comentar.

Respuestas (1)

Joe Vinciguerra
Joe Vinciguerra el 6 de Abr. de 2023
In addition to the comment from @Dyuman Joshi, for the y-axis you could also use
ylim("tight")
if you want to let Matlab figure out the limits of your data and fit the axis tight to that.

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by