0

Given the following table (borrowed from here):

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

fig, ax = plt.subplots()

fig.patch.set_visible(False)
ax.axis('off')
ax.axis('tight')
df = pd.DataFrame(np.random.randn(10, 4), columns=list('ABCD'))
ax.table(cellText=df.values, colLabels=df.columns, loc='center')
fig.tight_layout()
plt.show()

I want to hide all lines save for those horizontal under each row (but not the bottom or top 2 rows). Is this level of control attainable? I tried ax.hlines, but the lines seemed to plot randomly.

1 Answer 1

1

I am not sure about the "but not the bottom or top 2 rows", can you specify?

Yet, to get only the horizontal lines, you can add the edges='horizontal' parameter:

ax.table(cellText=df.values, colLabels=df.columns, loc='center', edges='horizontal')

output: horizontal lines

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! From here, can you make it to the top and bottom lines (edges) do not appear?

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.