Quiver plot with a Third feature using background colour
1 次查看(过去 30 天)
显示 更早的评论
Could someone tell how can we add a third feature which is represented by the background color in the quiver plot?
As explained in a previous question and answer thread, how can we add an another property which is expectation value of sigma_z.
In the code above if we want to add another two line.
% before the 'for' loop
sigma_z = [1,0;0,-1]; %sigma_z
%After the for loop
expz = pagemtimes(pagemtimes(Psi,'ctranspose',sigma_z,'none'),Psi); % BL's change here
expz = reshape(expz,[M M]); % BL's change here
And if we want to reflect the magnitude of espectation value of z by background color of the quiver plot, is it possible in MATLAB?
PS: The magnitude of expz is very small (zero), still I want to know the way.
0 个评论
回答(1 个)
Aditya
2023-11-23
Hi Shubham,
I understand that you want to add a third feature which is represented by background color in the quiver plot. You can achieve this by using the “imagesc” function. Here's how you can modify your code to include it:
% Create the quiver plot with background color
figure;
imagesc(kx, ky, abs(expz)); % Plot the background color based on |expz|
colormap('jet'); % Set the colormap
colorbar; % Show the colorbar
hold on;
quiver(KX, KY, expx, expy); % Overlay the quiver plot
hold off;
In the code above, “abs(expz)” determines the color intensity of each point in the background, with the colormap set to “jet” for a range of colors. The “colorbar” provides a reference for the magnitude of “expz”.
For more information on the “imagesc” function and its properties, you can refer the below MATLAB documentation:
Hope this helps!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Vector Fields 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!