Quiver plot with a Third feature using background colour
4 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Aditya
on 23 Nov 2023
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 Comments
See Also
Categories
Find more on Vector Fields in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!