Why is a parfor loop making it so that I can't plot circles when using gscatter?

1 view (last 30 days)
I have been using gscatter to plot atom positions (labeled by color to indicate what structure the atoms have). Originally, I was plotting the atoms as stars, but now I need to change them to circles. What's interesting is that I also separately have made a change in a different section of the code. My input value to the gscatter command is obtained from a for loop earlier on in the code, but I changed it to a parfor loop to make it run faster. The code will still run, but it will only plot circles in the version that's just a for loop, and it still plots stars for the version with a parfor loop, even though I'm not telling it to do that anymore.
I also have it optionally plot the atoms colored by other means (such as rotation angle) using scatter, and those have no problem creating circles. Here is the code that should be plotting circles for the structure (as well as the code that actually works for the angle):
if isempty(plotStatus)
return
elseif strcmp(plotStatus,'structure')==1
valueset = [0 1 2 3];
structureValues=categorical(structureValues,valueset);
figure
gscatter(x,y,structureValues,'kgbr',[],20,'off')
axis image
axis off
elseif strcmp(plotStatus,'angle')==1
figure
scatter(x,y,15,thetaValues,'filled')
hold on
plot(nanX,nanY,'kx')
axis image
axis off
c = colorbar;
c.Label.String = '\theta (degrees)';
end
In this case, both structureValues and thetaValues come from the for/parfor loop earlier in the code. I have attached some images demonstrating what I'm talking about as well; the stars is the atoms sorted by structure and the circles are an example where they're sorted by angle. Please let me know if more information is needed.
Any help would be appreciated, thank you!
UPDATE
It appears that my code that uses the loop simply isn't registering any changes I make to the code, not just attempting to change the gscatter plot. I have no idea why this would be the case.
  4 Comments
Walter Roberson
Walter Roberson on 10 Jul 2023
Could you confirm that if you make only the change of parfor to for that the code starts doing what you want?
Darcey
Darcey on 11 Jul 2023
Edited: Darcey on 11 Jul 2023
No, you're right, if I take out the parfor loop it still doesn't work. I have a different version of the code that doesn't use a parfor loop so I assumed that was the problem, but that doesn't seem to be the case. It seems like my code just isn't updating as I change it, like it's not registering that changes are being made at all. It's really weird, even if I try to debug it by putting a marker on the first line of code, it doesn't stop. I'm not sure what would cause that, I'll have to look at it again.

Sign in to comment.

Accepted Answer

Darcey
Darcey on 11 Jul 2023
Moved: Steven Lord on 11 Jul 2023
Hey I just realized that I had 2 versions of the same file for some reason, problem solved. Thank you, and sorry about that.

More Answers (0)

Products


Release

R2023a

Community Treasure Hunt

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

Start Hunting!