0
votes

I have a dataframe such as the following:

      col_1  col_2  col_3
0              True           True           True
1              True           True           True
2              True           True           True
3              True           True           True
4              True           True           True

I would like to create a plot where:

  1. x axis is the index value

  2. y axis has got three rows (one for each column), where a scatter point is present on that row if it is False. Else it is not present.

Is this possible?

1
Columns in a scatter plot? Could you include an image of what you would like to accomplish? The code for any attempts you've made would be great too. And perhaps a more complete dataset where alle the values are not equal to True, since the cases where the values are False seem to be of more interest. - vestland

1 Answers

1
votes

Is it this what you are after? I've set some random elements to False just to illustrate.

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

df = pd.DataFrame([[True]*3]*5, columns=['col1', 'col2', 'col3'])
df.iloc[0, 2] = False
df.iloc[1, 1] = False
df.iloc[4, 0] = False

x, y = np.where(df == False)
y = y + 1  # just to match example columns names

plt.figure()
plt.scatter(x, y)
plt.show()