[英]Plotting a scatter plot of a dataframe
我有以下數據框:
A B C
0 0.691295 0.179792 0.062371
1 NaN 0.179915 0.102003
2 NaN 0.186998 0.102183
3 NaN 0.189350 0.102220
4 NaN 0.189637 0.103003
我如何繪制散點圖
x是從0到1的值范圍
y是列名(即,同一列中的所有值都應具有相同的y值),
每列值具有不同的顏色
IIUC,您可以這樣做:
import pandas as pd
# Just some values.
df = pd.DataFrame({
'a': np.random.rand(5),
'b': np.random.rand(5),
'c': np.random.rand(5)})
# Now for the plots.
# Plot a values at 1.
plot(df.a, [1] * 5, '+');
# Plot b values at 2.
plot(df.b, [2] * 5, '+');
# Plot c values at 3.
plot(df.c, [3] * 5, '+');
# Ensure extreme points visible.
ylim(0, 4)
# Set the ticks to 'a', 'b', and 'c'.
yticks([1, 2, 3], ['a', 'b', 'c']);
這給出了:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.