0

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. Commented Jan 6, 2020 at 20:51

1 Answer 1

1

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()
Sign up to request clarification or add additional context in comments.

2 Comments

I'd like to do this with plotly, if possible. And, ideally, the y axis would be labeled with the names of the columns rather than arbitrary y values.
Oops, sorry, had totally missed the first word in your post!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.