How to have a same size of the image with out distortion in a subplot along with the graph?
Hello all,
I am trying to place an image along with a plot in subplot. But when i am trying to plot the image is small compared to the size of the plot. I need both of them to be in the same size. I also used "imagesc(img);" , but the image looks distorted. Please help me with this. Thanks in advance.
My code:
set(0,’Units’,’pixels’);
scrsz = get(0,’ScreenSize’);
scr_width = scrsz(3);
scr_heigth = scrsz(4);
img = imread(‘Geometry.jpg’);
Z = readtable(‘Fig1.xlsx’);
alpha = 0.1;
figure(‘Position’, round([alpha*scr_width alpha*scr_heigth (1-2*alpha)*scr_width (1-2*alpha)*scr_heigth ]));
% 1. Image subplot
subplot(1,4,1);
% imagesc(img);
imshow(img);
axis off
data = table2array(Z) ;
subplot(1,4,2)
plot(data(:,1), data(:,2), ‘k’,’linewidth’, 2);
hold off
grid on
xlabel(‘xxx’);
ylabel(‘yyy’);
subplot(1,4,3)
plot(data(:,3), data(:,4), ‘linewidth’, 2);
hold on
str = ‘#0072BD’;
color = sscanf(str(2:end),’%2x%2x%2x’,[1 3])/255;
plot(data(:,5), data(:,6), ‘*’, ‘Color’, color, ‘linewidth’, 2);
hold on
plot(data(:,7), data(:,8), ‘linewidth’, 2);
hold on
str = ‘#EDB120’;
color = sscanf(str(2:end),’%2x%2x%2x’,[1 3])/255;
plot(data(:,9), data(:,10), ‘*’, ‘Color’, color, ‘linewidth’, 2);
hold on
plot(data(:,11), data(:,12), ‘linewidth’, 2);
hold on
str = ‘#77AC30’;
color = sscanf(str(2:end),’%2x%2x%2x’,[1 3])/255;
plot(data(:,13), data(:,14), ‘*’, ‘Color’, color, ‘linewidth’, 2);
hold on
plot(data(:,15), data(:,16), ‘linewidth’, 2);
hold on
str = ‘#A2142F’;
color = sscanf(str(2:end),’%2x%2x%2x’,[1 3])/255;
plot(data(:,17), data(:,18), ‘*’, ‘Color’, color, ‘linewidth’, 2);
hold off
% legend(‘Wygnanski&Fiedler (1969)’, ‘Standard k-in’, ‘RNG k-in’, ‘Realizable k-in’,…
% ‘SST k-omega’, ‘Location’, ‘northeast’);
grid on
xlabel(‘xxx’);
ylabel(‘yyy’);
subplot(1,4,4)
plot(data(:,19), data(:,20), ‘linewidth’, 2);
hold on
str = ‘#0072BD’;
color = sscanf(str(2:end),’%2x%2x%2x’,[1 3])/255;
plot(data(:,21), data(:,22), ‘*’, ‘Color’, color, ‘linewidth’, 2);
hold on
plot(data(:,23), data(:,24), ‘linewidth’, 2);
hold on
str = ‘#EDB120’;
color = sscanf(str(2:end),’%2x%2x%2x’,[1 3])/255;
plot(data(:,25), data(:,26), ‘*’, ‘Color’, color, ‘linewidth’, 2);
hold on
plot(data(:,27), data(:,28), ‘linewidth’, 2);
hold on
str = ‘#77AC30’;
color = sscanf(str(2:end),’%2x%2x%2x’,[1 3])/255;
plot(data(:,29), data(:,30), ‘*’, ‘Color’, color, ‘linewidth’, 2);
hold on
plot(data(:,31), data(:,32), ‘linewidth’, 2);
hold on
str = ‘#A2142F’;
color = sscanf(str(2:end),’%2x%2x%2x’,[1 3])/255;
plot(data(:,33), data(:,34), ‘*’, ‘Color’, color, ‘linewidth’, 2);
hold off
% legend(‘Wygnanski&Fiedler (1969)’, ‘Standard k-in’, ‘RNG k-in’, ‘Realizable k-in’,…
% ‘SST k-omega’, ‘Location’, ‘northeast’);
grid on
xlabel(‘xxx’);
ylabel(‘yyy’);Hello all,
I am trying to place an image along with a plot in subplot. But when i am trying to plot the image is small compared to the size of the plot. I need both of them to be in the same size. I also used "imagesc(img);" , but the image looks distorted. Please help me with this. Thanks in advance.
My code:
set(0,’Units’,’pixels’);
scrsz = get(0,’ScreenSize’);
scr_width = scrsz(3);
scr_heigth = scrsz(4);
img = imread(‘Geometry.jpg’);
Z = readtable(‘Fig1.xlsx’);
alpha = 0.1;
figure(‘Position’, round([alpha*scr_width alpha*scr_heigth (1-2*alpha)*scr_width (1-2*alpha)*scr_heigth ]));
% 1. Image subplot
subplot(1,4,1);
% imagesc(img);
imshow(img);
axis off
data = table2array(Z) ;
subplot(1,4,2)
plot(data(:,1), data(:,2), ‘k’,’linewidth’, 2);
hold off
grid on
xlabel(‘xxx’);
ylabel(‘yyy’);
subplot(1,4,3)
plot(data(:,3), data(:,4), ‘linewidth’, 2);
hold on
str = ‘#0072BD’;
color = sscanf(str(2:end),’%2x%2x%2x’,[1 3])/255;
plot(data(:,5), data(:,6), ‘*’, ‘Color’, color, ‘linewidth’, 2);
hold on
plot(data(:,7), data(:,8), ‘linewidth’, 2);
hold on
str = ‘#EDB120’;
color = sscanf(str(2:end),’%2x%2x%2x’,[1 3])/255;
plot(data(:,9), data(:,10), ‘*’, ‘Color’, color, ‘linewidth’, 2);
hold on
plot(data(:,11), data(:,12), ‘linewidth’, 2);
hold on
str = ‘#77AC30’;
color = sscanf(str(2:end),’%2x%2x%2x’,[1 3])/255;
plot(data(:,13), data(:,14), ‘*’, ‘Color’, color, ‘linewidth’, 2);
hold on
plot(data(:,15), data(:,16), ‘linewidth’, 2);
hold on
str = ‘#A2142F’;
color = sscanf(str(2:end),’%2x%2x%2x’,[1 3])/255;
plot(data(:,17), data(:,18), ‘*’, ‘Color’, color, ‘linewidth’, 2);
hold off
% legend(‘Wygnanski&Fiedler (1969)’, ‘Standard k-in’, ‘RNG k-in’, ‘Realizable k-in’,…
% ‘SST k-omega’, ‘Location’, ‘northeast’);
grid on
xlabel(‘xxx’);
ylabel(‘yyy’);
subplot(1,4,4)
plot(data(:,19), data(:,20), ‘linewidth’, 2);
hold on
str = ‘#0072BD’;
color = sscanf(str(2:end),’%2x%2x%2x’,[1 3])/255;
plot(data(:,21), data(:,22), ‘*’, ‘Color’, color, ‘linewidth’, 2);
hold on
plot(data(:,23), data(:,24), ‘linewidth’, 2);
hold on
str = ‘#EDB120’;
color = sscanf(str(2:end),’%2x%2x%2x’,[1 3])/255;
plot(data(:,25), data(:,26), ‘*’, ‘Color’, color, ‘linewidth’, 2);
hold on
plot(data(:,27), data(:,28), ‘linewidth’, 2);
hold on
str = ‘#77AC30’;
color = sscanf(str(2:end),’%2x%2x%2x’,[1 3])/255;
plot(data(:,29), data(:,30), ‘*’, ‘Color’, color, ‘linewidth’, 2);
hold on
plot(data(:,31), data(:,32), ‘linewidth’, 2);
hold on
str = ‘#A2142F’;
color = sscanf(str(2:end),’%2x%2x%2x’,[1 3])/255;
plot(data(:,33), data(:,34), ‘*’, ‘Color’, color, ‘linewidth’, 2);
hold off
% legend(‘Wygnanski&Fiedler (1969)’, ‘Standard k-in’, ‘RNG k-in’, ‘Realizable k-in’,…
% ‘SST k-omega’, ‘Location’, ‘northeast’);
grid on
xlabel(‘xxx’);
ylabel(‘yyy’); Hello all,
I am trying to place an image along with a plot in subplot. But when i am trying to plot the image is small compared to the size of the plot. I need both of them to be in the same size. I also used "imagesc(img);" , but the image looks distorted. Please help me with this. Thanks in advance.
My code:
set(0,’Units’,’pixels’);
scrsz = get(0,’ScreenSize’);
scr_width = scrsz(3);
scr_heigth = scrsz(4);
img = imread(‘Geometry.jpg’);
Z = readtable(‘Fig1.xlsx’);
alpha = 0.1;
figure(‘Position’, round([alpha*scr_width alpha*scr_heigth (1-2*alpha)*scr_width (1-2*alpha)*scr_heigth ]));
% 1. Image subplot
subplot(1,4,1);
% imagesc(img);
imshow(img);
axis off
data = table2array(Z) ;
subplot(1,4,2)
plot(data(:,1), data(:,2), ‘k’,’linewidth’, 2);
hold off
grid on
xlabel(‘xxx’);
ylabel(‘yyy’);
subplot(1,4,3)
plot(data(:,3), data(:,4), ‘linewidth’, 2);
hold on
str = ‘#0072BD’;
color = sscanf(str(2:end),’%2x%2x%2x’,[1 3])/255;
plot(data(:,5), data(:,6), ‘*’, ‘Color’, color, ‘linewidth’, 2);
hold on
plot(data(:,7), data(:,8), ‘linewidth’, 2);
hold on
str = ‘#EDB120’;
color = sscanf(str(2:end),’%2x%2x%2x’,[1 3])/255;
plot(data(:,9), data(:,10), ‘*’, ‘Color’, color, ‘linewidth’, 2);
hold on
plot(data(:,11), data(:,12), ‘linewidth’, 2);
hold on
str = ‘#77AC30’;
color = sscanf(str(2:end),’%2x%2x%2x’,[1 3])/255;
plot(data(:,13), data(:,14), ‘*’, ‘Color’, color, ‘linewidth’, 2);
hold on
plot(data(:,15), data(:,16), ‘linewidth’, 2);
hold on
str = ‘#A2142F’;
color = sscanf(str(2:end),’%2x%2x%2x’,[1 3])/255;
plot(data(:,17), data(:,18), ‘*’, ‘Color’, color, ‘linewidth’, 2);
hold off
% legend(‘Wygnanski&Fiedler (1969)’, ‘Standard k-in’, ‘RNG k-in’, ‘Realizable k-in’,…
% ‘SST k-omega’, ‘Location’, ‘northeast’);
grid on
xlabel(‘xxx’);
ylabel(‘yyy’);
subplot(1,4,4)
plot(data(:,19), data(:,20), ‘linewidth’, 2);
hold on
str = ‘#0072BD’;
color = sscanf(str(2:end),’%2x%2x%2x’,[1 3])/255;
plot(data(:,21), data(:,22), ‘*’, ‘Color’, color, ‘linewidth’, 2);
hold on
plot(data(:,23), data(:,24), ‘linewidth’, 2);
hold on
str = ‘#EDB120’;
color = sscanf(str(2:end),’%2x%2x%2x’,[1 3])/255;
plot(data(:,25), data(:,26), ‘*’, ‘Color’, color, ‘linewidth’, 2);
hold on
plot(data(:,27), data(:,28), ‘linewidth’, 2);
hold on
str = ‘#77AC30’;
color = sscanf(str(2:end),’%2x%2x%2x’,[1 3])/255;
plot(data(:,29), data(:,30), ‘*’, ‘Color’, color, ‘linewidth’, 2);
hold on
plot(data(:,31), data(:,32), ‘linewidth’, 2);
hold on
str = ‘#A2142F’;
color = sscanf(str(2:end),’%2x%2x%2x’,[1 3])/255;
plot(data(:,33), data(:,34), ‘*’, ‘Color’, color, ‘linewidth’, 2);
hold off
% legend(‘Wygnanski&Fiedler (1969)’, ‘Standard k-in’, ‘RNG k-in’, ‘Realizable k-in’,…
% ‘SST k-omega’, ‘Location’, ‘northeast’);
grid on
xlabel(‘xxx’);
ylabel(‘yyy’); subplot, image MATLAB Answers — New Questions