Problem With Axis Limits

Hello all,
First post here but have found many a solution previously so keep up the good work!
I am working on a Script that produces various loads exerted on a Gearbox and am running into some issues with my plots.
I am plotting both Shear Force and Bending Moment in the same graph which is working perfectly fine with the only issue being that MATLAB sets my maximum x-axis value at 0.45m whereas the shaft is only 0.411m. If I use either axis (ymin ymax 0 0.411) or xlim (0 0.411) or ANY value below the 0.45 default, MATLAB shrinks the entire graph to fit between those values rather than just cutting off the empty space. If someone could tell me what I am doing wrong that would be great!
Code:
figure (1);
hold on;
set (figure (1), 'outerposition', [390 50 750 750]);
set (gca, 'units', 'normalized', 'position', [0.125, 0.125, 0.75, 0.75])
[ax, p1, p2] = plotyy (x_V, V_Y, x_M, M_Y);
plot (x_M, M_Yo, 'r--')
xlim ([0 0.411];
title ({'Shear Force & Bending Moment' ; '[Y-Plane]'});
xlabel ({'Distance From Bearing 1' ; '[m]'});
ylabel (ax(1),{'Shear Force' ; '[N]'});
ylabel (ax(2),{'Bending Moment' ; '[Nm]'})
hold off;

Respuestas (1)

Star Strider
Star Strider el 28 de Nov. de 2015

0 votos

I can’t run your code so only offer a few things for you to experiment with:
axis tight
axis equal
and see the documentation for axis for all the wonderful things the function can do.

4 comentarios

Conor J Crickmore
Conor J Crickmore el 28 de Nov. de 2015
Thank you for your response.
I have already tried axis tight to no avail and using axis equal did strange things unfortunately.
I can only imagine it is to do with the fact that I am plotting two separate data sets, with different y-axis, on the same figure. The Figure shows both the Shear Force and Bending Moment on the Shaft. When using any form of axis restriction the Shear Force plot remains correct but the Bending Moment plot is 'shrunk' to fit within the new limits.
Star Strider
Star Strider el 28 de Nov. de 2015
My guess is that you have two different x-value ranges, and while they may overlap, they’re likely not the same values. If the appearance of the plot is important, and your data are relatively continuous and don’t have appreciable noise, one option you may want to consider is to use the interp1 function to interpolate both to the same x-values.
If this is not your problem, and since I don’t have your code or even an image of your plot to refer to, I’ll delete my Answer in a few minutes, since it didn’t turn out to be one.
Conor J Crickmore
Conor J Crickmore el 29 de Nov. de 2015
Editada: Conor J Crickmore el 29 de Nov. de 2015
Ah! I think you may be correct there.
While both plots start at x = 0 and end at x = 0.411, the Shear Force plot have six values (it is a step graph) while the Bending Moment only has four - is that what is causing the issue?
BMx = 0, 0.0075, 0.227, 0.411
SFx = 0, 0.075, 0.075, 0.227, 0.227, 0.411
How would I upload an image of the figure to help further?
Star Strider
Star Strider el 29 de Nov. de 2015
It could be. This is just my current hypothesis.
To upload the figure as an image, first use the floppy-disk icon in the figure window to save the plotted figure as a .png image. Then back here in MATLAB Answers, use the brown-framed green landscape icon to upload the image. Be sure to complete both the ‘Choose file’ and ‘Insert image’ steps.

Iniciar sesión para comentar.

Categorías

Más información sobre Creating, Deleting, and Querying Graphics Objects en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 28 de Nov. de 2015

Comentada:

el 29 de Nov. de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by