yt-project / yt

Main yt repository
http://yt-project.org
Other
454 stars 272 forks source link

How to change the particle size in function "ParticlePhasePlot" #4900

Closed Horizonatpku closed 2 months ago

Horizonatpku commented 2 months ago

Bug report

Bug summary Hi everyone,

I want to change the the particle size when using the class "ParticlePhasePlot", however, there is no such options in the class yt.visualization.particle_plots.ParticlePhasePlot

I know we can change the particle size by setting the "s=size" in matplotlib.scatter, how can we change the particle size in the class "ParticlePhasePlot",

I will be appreciate if you can give me some suggestions, thank a lot!

best wishes, Yifeng He

Code for reproduction

# Paste your code here
class yt.visualization.particle_plots.ParticlePhasePlot
(
data_source, x_field, y_field, z_fields=None, color='b', 
x_bins=800, y_bins=800, weight_field=None, deposition='ngp', 
fontsize=18, figure_size=8.0, shading='nearest'
)

class matplotlib.pyplot.scatter
(
x, y, s=None, c=None, marker=None, cmap=None, norm=None, 
vmin=None, vmax=None, alpha=None, linewidths=None, *, 
edgecolors=None, plotnonfinite=False, data=None, **kwargs
)
neutrinoceros commented 2 months ago

ParticlePhasePlot does not use markers (as matplotlib's scatter method does) to represent individual points. Rather, it creates a buffer image (a 2D array of floats) and displays it using matplotlib's imshow method. This means that the display size of any individual particle is actually a "pixel" in that array, whose resolution is controled byx_binsxy_bins. Does this answer your question ?

Horizonatpku commented 2 months ago

I got it, reducing x_bins and y_bins can make the particle phase more 'clear'. Thanks a lot!