Effacer les filtres
Effacer les filtres

Is there a way to set special non-linear axis spacing to fit image?

4 vues (au cours des 30 derniers jours)
Marius Hammer
Marius Hammer le 12 Fév 2019
Commenté : Chris Hooper le 18 Jan 2021
Hi,
In a Matlab program I am dealing with some wave surface elavation calculation which results I have to compare with a figure.
Now instead of manually checking the figure (like on the left one below), it would be nice to have the Matlab plot my resulted data point on the figure (Right figure below).
However the figure has some odd axis spacing which I can't really figure out what is. In the beginnning I thought it might be log spaced, but haven't had any luck with that or any other spacing so far.
So would like to ask here if there is a way to make Matlab fit the spacing of the figure, or what kind of spacing it might be?
Just using regular spacing, the data point gets placed as shown on the right figure with the red dot while it should, if the spacing was correct, be located approximetely where I've placed the black dot.
h = 100; % Depth [m]
H = 4; % Wave height [m]
T = 8; % Wave period [s]
g = 9.816; % Acceleration of gravity [m/s^2]
% Le Mehaute factors
LeM_y = H/(g*T^2); % = 0.1592
LeM_x = h/(g*T^2); % = 0.0064
% Plot of Le Mehaute diagram (1976)
figure(2)
% Plot Image
xrng = [0 0.2]; % x limit
yrng = [0.00005 0.05];% y limit
img = imread('LeMauhaute.png'); % import image
image(xrng,yrng,img); % plot image
set(gca,'YTickLabel', [], 'XTickLabel', []); % get rid of pixel (image) ticklabels
axes('Position',get(gca,'Position'),'Color','none'); %color=none to make the image visible
hold on
% Plot data points on image
plot(LeM_x,LeM_y,'.r','MarkerSize',30);
% Plot options
ylim(yrng); % define figure x limit
xlim(xrng); % define figure y limit
xlabel('$\frac{h}{g T^2}$','interpreter','latex','FontSize',20);
ylabel('$\frac{H}{g T^2}\hspace{1em}$','interpreter','latex','FontSize',20); set(get(gca,'YLabel'),'Rotation',0)
title('Le Mehaute diagram (1976)')
set(gcf, 'Position', [100, 100, 700, 600]);
  1 commentaire
Chris Hooper
Chris Hooper le 18 Jan 2021
trying to figure out the same thing for the same plot right now - had the same idea of pulling this image off matlab to check validty of wave theory. Any luck in the end?

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Formatting and Annotation dans Help Center et File Exchange

Produits


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by