Filter löschen
Filter löschen

an error in displaying a plot from scatter3?

3 Ansichten (letzte 30 Tage)
Emily
Emily am 11 Sep. 2023
Verschoben: Walter Roberson am 11 Sep. 2023
I'm trying to make a movie of some data using scatter3. I found particular data that seems to break my plotting. Here is my minimal working example:
% Define the troublesome data
LocalP01TimesAbbrev= [0.985141016248456 0.983832758385265 0.982463398432200; ...
0.014564614437997 0.015818194233200 0.017125250702120; ...
0.014473309566424 0.015711762527657 0.017002051251182];
LocalP10TimesAbbrev = [ 0.014858983751545 0.016167241614735 0.017536601567800; ...
0.985435385562003 0.984181805766800 0.982874749297880; ...
0.985526690433576 0.984288237472344 0.982997948748818];
ProbAlphaTimesAbbrev = [ 0.173075907671362 0.170950942612534 0.168765455538531; ...
0.263402471915559 0.260491423443426 0.257493774027376; ...
0.432533162447323 0.427194569248721 0.421701733201043];
LocalPhi0001TimesAbbrev= [ 0.467221621294768 0.486636417067630 0.506044435239474; ...
0.991724460901591 -0.987830595863805 -0.967391124238550; ...
0.968975981089195 0.988486840582777 -0.992006142330032];
LocalPhi1001TimesAbbrev = [ 1.455931021018426 1.454016681105492 1.452092703739240;...
0.533792771964366 -1.464742280598276 -1.463270085144922 ; ...
0.501499482572618 0.501561621075348 -1.498376287448080];
% define figure for movie
figure('InnerPosition',[488 338 889 420]);
for tstep=1:3
% Make scatter plot movie frames
CircleSize = 10000*ProbAlphaTimesAbbrev(:,tstep); CircleSize(CircleSize<10^-15)=10^-15;
CircleColor = 100*ProbAlphaTimesAbbrev(:,tstep); CircleColor(CircleColor<10^-15) = 10^-15;
scatter3(LocalP01TimesAbbrev(:,tstep),LocalP10TimesAbbrev(:,tstep),LocalPhi1001TimesAbbrev(:,tstep),CircleSize,CircleColor,'filled');
xlim([0,1]); xlabel('p_{01}'); ylim([0,1]); ylabel('p_{10}'); zlim([-1,1]); zlabel('(\phi_{10}-\phi_{01})/\pi, phase between 10 and 01 states')
title(sprintf('Conditional state of sites 1,2, \\surd{p_{00}}e^{i(\\phi_{00}-\\phi_{01})}|00> +\\surd{p_{01}}|01> + e^{i(\\phi_{10}-\\phi_{01})}\\surd{p_{10}}|10>+ e^{i(\\phi_{11}-\\phi_{01})}\\surd{p_{11}}|11>, time= %d.',tstep));
drawnow
Mymovie(tstep) = getframe(gcf);
filename2 = sprintf('TestScatterPlot.gif');
exportgraphics(gca,filename2,"Append",true);
end
% The ending plot has no data points on it when I run the above loop.
% However making a new figure and plotting the same data does show data points.
figure; scatter3(LocalP01TimesAbbrev(:,tstep),LocalP10TimesAbbrev(:,tstep),LocalPhi1001TimesAbbrev(:,tstep),CircleSize,CircleColor,'filled');
xlim([0,1]); xlabel('p_{01}'); ylim([0,1]); ylabel('p_{10}'); zlim([-1,1]); zlabel('(\phi_{10}-\phi_{01})/\pi, phase between 10 and 01 states')
title(sprintf('Conditional state of sites 1,2, \\surd{p_{00}}e^{i(\\phi_{00}-\\phi_{01})}|00> +\\surd{p_{01}}|01> + e^{i(\\phi_{10}-\\phi_{01})}\\surd{p_{10}}|10>+ e^{i(\\phi_{11}-\\phi_{01})}\\surd{p_{11}}|11>, time= %0.3f.',tstep));
  1 Kommentar
Walter Roberson
Walter Roberson am 11 Sep. 2023
It works for me when I try it on my Mac (R2023b prerelease at least)
Historically, imwrite() had a problem when you specified 'WriteMode', 'append' for a fiie that did not exist. However, you are not using imwrite()

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

VINAYAK LUHA
VINAYAK LUHA am 11 Sep. 2023
Verschoben: Walter Roberson am 11 Sep. 2023
Hi Emily,
If my understanding is correct, a purple sphere is also being plotted every frame, which doesn't show up in the plot due to limit restriction imposed on axis, however regarding the yellow sphere in frame three, it's center roughly has the coordinates , [0,0.98,-1.46] and since your z lim is set as [-1,1], it doesn't get displayed in the plot.
Hope this helps.
  1 Kommentar
Emily
Emily am 11 Sep. 2023
Verschoben: Walter Roberson am 11 Sep. 2023
Vinayak, thank you! You are correct. I hadn't noticed that. If you would like to upgrade your comment to an answer, I'd accept it.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Produkte


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by