I would like to vary the marker size in my seaborn pointplot according to a numpy array representing the sample size.
markersize_array = np.array([[10, 5, 6]])
Feeding markersize_array
to the markersize
keyword produces an error:
<code>TypeError: only length-1 arrays can be converted to Python scalars
</code>
<code>TypeError: only length-1 arrays can be converted to Python scalars
</code>
TypeError: only length-1 arrays can be converted to Python scalars
Here is some example code:
<code>penguins = sns.load_dataset("penguins")
fig, ax = plt.subplots(1, 1, figsize=(2, 2))
markersize_array = np.array([[10, 5, 6]])
sns.pointplot(
data=penguins,
x="body_mass_g",
y="island",
ax=ax,
estimator=np.mean,
errorbar=('ci', 95),
capsize=0,
color="k",
log_scale=False,
linestyle="none",
marker="s",
markersize=np.array([[5]]),
# markersize=markersize_array, # <- I need this
)```
Is there a way to make this happen?
[![Constant Marker Size][1]][1]
[1]: https://i.sstatic.net/0TEtH2CY.png
</code>
<code>penguins = sns.load_dataset("penguins")
fig, ax = plt.subplots(1, 1, figsize=(2, 2))
markersize_array = np.array([[10, 5, 6]])
sns.pointplot(
data=penguins,
x="body_mass_g",
y="island",
ax=ax,
estimator=np.mean,
errorbar=('ci', 95),
capsize=0,
color="k",
log_scale=False,
linestyle="none",
marker="s",
markersize=np.array([[5]]),
# markersize=markersize_array, # <- I need this
)```
Is there a way to make this happen?
[![Constant Marker Size][1]][1]
[1]: https://i.sstatic.net/0TEtH2CY.png
</code>
penguins = sns.load_dataset("penguins")
fig, ax = plt.subplots(1, 1, figsize=(2, 2))
markersize_array = np.array([[10, 5, 6]])
sns.pointplot(
data=penguins,
x="body_mass_g",
y="island",
ax=ax,
estimator=np.mean,
errorbar=('ci', 95),
capsize=0,
color="k",
log_scale=False,
linestyle="none",
marker="s",
markersize=np.array([[5]]),
# markersize=markersize_array, # <- I need this
)```
Is there a way to make this happen?
[![Constant Marker Size][1]][1]
[1]: https://i.sstatic.net/0TEtH2CY.png