how to plot two graphs in one plot
显示 更早的评论
I have created the following plot but i want to reverse the y direction(i,e top left corner should start with 50 in y direction) but if i reverse the y direction the vectors will point in downward direction and i dont want the vectors to point in downward direction if i reverse the y direction kindly help me . .
5 个评论
Adam Danz
2021-4-23
Do you want the colored surface to flip vertically or do you want the surface and quiver plots to remain how they are but only flip the y-ticks?
HARIKRISHNA B YADULADODDI
2021-4-24
Jonas
2021-4-24
then maybe
yticklabels(flip(yticklabels()))
is what you want
Adam Danz
2021-4-24
HARIKRISHNA B YADULADODDI's duplicate question moved here
The Y-axis ticks go like 0,5,10- - - - - 50
I want the plot to remain as it is, but flip the ticks so that they go like 50 45 40 - - - - - - 5,0.
Can this be done? please find the code and file for reference.
clear all;close all;clc
format long
%--------Reading velocity data-------%
fid=fopen('50112.txt');
fulltext=textscan(fid,'%s','delimiter','\n');
numberofgridpoints=length(fulltext{1});
fclose(fid);
n=numberofgridpoints/200;
fid=fopen('50112.txt');
datamatrix=fscanf(fid,'%f%f%f%f',[4,inf]);
%-------stroing velocity-----------%
for i=1:200
c=i-1;
for j=1:n
d=(c*n)+j;
x(j)=datamatrix(1,j);
y(j)=datamatrix(2,j);
u(i,j)=datamatrix(3,d);
v(i,j)=datamatrix(4,d);
end
end
x1(1:13,1:20)=0;
y1(1:13,1:20)=0;
a=-19;
b=10;
for j=1:20
for i=1:13
x1(i,j)=a;
end
a=a+2;
end
x1=reshape(x1,1,260)
for i=1:13
for j=1:20
y1(i,j)=b;
end
b=b+1.92307692307;
end
y1=reshape(y1,1,260)
%-----------Ensemble mean------------%
addu(1:n)=0;
addv(1:n)=0;
for j=1:n
for i=1:200
addu(1,j)=addu(1,j)+u(i,j);
addv(1,j)=addv(1,j)+v(i,j);
end
avgu(1,j)=addu(1,j)/200;
avgv(1,j)=addv(1,j)/200;
end
%---------------------plot--------%
figure('name','ENSEMBLE AVARAGE FOR 50112')
rectangle('Position',[-26.75 0 53.55 50]);
xlabel('x (mm)')
ylabel('y (mm)')
axis equal
axis ([-25 25 0 50])
set(gca,'ytick',0:10:50)
axis tight
hold on
rectangle('Position',[-26.75 40 53.5 5],'FaceColor',[0.502 0.502 0.502])
text (-2.5,42.5,'Piston','Color','black','FontSize',14)
y=yline(1.2,'r','TDC')
y.LineWidth = 1;
y.LabelHorizontalAlignment='center'
y.LabelVerticalAlignment='middle'
hold on
magnitude=sqrt(avgu.^2+avgv.^2);
magnitude=reshape(magnitude,[13,20]);
[X,Y]=meshgrid(-19:2:19,10:1.9230769:33.0769230);
contourf(X,Y,magnitude,100,'linestyle','none')
hold on
h=quiver(x1,y1,avgu,avgv,'color','black');
set(gca,'ydir','reverse')
axis equal
c = colorbar;
c.Label.String = 'V [m/s]'
c.Label.FontSize =14;
c.FontWeight = 'normal'
hold off
output: [see figure in main question]
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Vector Fields 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



