简体   繁体   中英

Changing marker's size in stripplot according to data value

I'm trying to create a categorical plot in which the size of each marker reflects some magnitude of the corresponding sample, as in the following example using the preloaded tips data(upper plot https://i.stack.imgur.com/pRn0x.png ):

import seaborn as sns

sns.set(style="whitegrid")
tips = sns.load_dataset("tips")
 ax = sns.stripplot("day", "total_bill", data=tips, palette="Set2", size=tips["size"]*5, edgecolor="gray", alpha=.25)

But when I try the same with my own data, all the markers have the same size (lower plot https://i.stack.imgur.com/pRn0x.png ):

import seaborn as sns
import pandas as pd

df = pd.read_csv("python_plot_test3.csv")
sns.set(style="whitegrid")
ax = sns.stripplot("log10p_value","term_name",  data=df, palette="Set2", size=df['precision'], edgecolor="gray", alpha=.50)

I suspected the datatypes were not the same, but it didn't seem so,
although, when I print df['precision'] it returns name and dtype
and when I print tips["size"] it also returns its length. Could someone give me a hint? I found how to change it in scatter plots, but nothing on categorical plots.


my data data:

term_name,log10p_value,precision
muscle structure development,33.34122617,15
anatomical structure morphogenesis,32.91330177,5
muscle system process,31.61813233,11
regulation of multicellular organismal process,30.84862451,25
system development,29.16494157,36
muscle cell differentiation,28.79114555,11

Okay, so looks like relplot is the right kind of function for this, at first I guessed it was specific for continuous data, but it also can handle categorized data. Although, I still don't understand why stripplot worked with the example data.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM