我有一个 Pandas 数据框:
--------------------------------------
| field_0 | field_1 | field_2 |
--------------------------------------
| 0 | 1.5 | 2.9 |
--------------------------------------
| 1 | 1.3 | 2.6 |
--------------------------------------
| : |
--------------------------------------
| 1 | 2.1 | 3.2 |
--------------------------------------
| 0 | 1.1 | 2.1 |
--------------------------------------
我可以为 field_1 与 field_2 创建散点图,如下所示:
%matplotlib notebook
import matplotlib.pyplot as plt
import matplotlib
matplotlib.style.use('ggplot')
my_df.plot(x='field_1', y='field_2', kind = 'scatter')
但是,我想知道是否可以在图中包含 field_0?所以当field_0 = 0时,点为蓝色;当 field_1 = 1 时,该点为红色。
谢谢!
最佳答案
关于python - Pandas :在散点图中使用颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39561364/