Reputation: 51
I am trying to draw a scatter plot with Plotly Express and facing a problem when setting the size of the markers. So this is the NumPy array that contains the numerical values in accordance to which, I want the marker size.
[0. 0. 0. 0. 0. 0.
0. 0. 0.53061224 0.65306122 0.28571429 1.
0.48979592 0.53061224 0. 0.65306122]
When I set the arguments in
px.scatter(size = size_array)
The markers on the plot with size 0 gets dissapeared, because literaly they have 0 size.
Is there any workaround this? So that markers which get 0 value are also visible on the plot?
I've attached the plot screenshot for reference, thanks.
EDIT I have replicated the whole issue here: https://gist.github.com/SakshamSingh-v2/5eb27d728f572c97ad67a4e5def346c0
Also One solution is to add a constant to the whole array, basically increasing the 0 to some value, but here the values represent severity. So increasing these values might give a mis-representation. I am thinking of a solution like in which I could map the 0 to some specified marker size.
Upvotes: 3
Views: 3105
Reputation: 27440
Yes, you can set the sizemin
attribute (in pixels!): https://plotly.com/python/reference/scatter/#scatter-marker-sizemin
Upvotes: 2
Reputation: 1290
Maybe you can copy that array and add constant value. So difference between initial values remain the same.
0 -> 1.00000000 0.53061224 -> 1.53061224
For hover information you can select your original array.
Upvotes: -1