I'm trying to plot a dataframe looks like this:
Quarter, score
1890.1, NaN
1890.2, 0.000000
1890.2, 0.000000
1890.2, -0.073413
1890.2, 0.000000
1890.3, NaN
1890.4, NaN
1891.1, NaN
1891.2, NaN
1891.3, NaN
1891.4, NaN
1892.1, NaN
1892.2, 0.000000
1892.3, 0.000000
In order to do error bar plot, I used seaborn pointplot. My problem is, the NaN values are not shown. So I get a plot with gaps like this: Is there any way to let seaborn show the missing data with a line? Thanks a lot for your help!
My code are as follows:
a4_dims = (15, 8.27)
fig, ax = plt.subplots(figsize=a4_dims)
ax = sns.pointplot(x="Quarter", y="score", data=df, aspect=2.5, capsize=.5)
plt.xticks(rotation=45)
plt.tight_layout()
Maybe you can try setting join
'If True, lines will be drawn between point estimates at the same hue level.'
Alternatively, you could use:
df['score']=df['score'].fillna(method='ffill')
depending on how you would like the line to be filled you can use
ffill: propagate last valid observation forward to next valid bfill: use NEXT valid observation to fill gap
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.