简体   繁体   English

如何使用 plot 为特定行分散 plot 使用 plotly

[英]How to plot scatter plot for specific rows using plotly

I want to plot a scatter plot for specific day.How to plot scatter with only two columns [Saturday and Sunday]?我想 plot 散布 plot 特定日期。如何 plot 散布只有两列 [星期六和星期日]?

px.scatter(
           df, x="total_bill", y="tip", 
           color="size", facet_col="day"
)


df.day.value_counts()

Sat     87
Sun     76
Thur    62
Fri     19
Name: day, dtype: int64

This is scatter plotted for all columns.这是所有列的散点图。

在此处输入图像描述

You just need to filter your df.你只需要过滤你的df。 It doesn't matter if you do so before or when you call px无论您是在调用 px 之前还是调用px时都这样做

import plotly.express as px
df = px.data.tips()

px.scatter(df[df["day"].isin(["Sat", "Sun"])],
           x="total_bill",
           y="tip", 
           color="size",
           facet_col="day"
)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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