Why is a parfor loop making it so that I can't plot circles when using gscatter?
1 view (last 30 days)
Show older comments
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
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?
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Matrix Indexing 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!