0

I want to create Matplotlib tables to present some data and wanted to add lines for every row. I thought that axhline was exactly what I needed. However, I ran into some problems. The axline function adds a line for every row, but it isn't aligned 100% correct, so it needs some adjustments, but that seems impossible. I've tried to adjust the coordinates in the function but without any results, only when I don't work with the index it yields different yet unpredictable results. Am I doing something wrong? Can someone help me?

The code beneath loops over the number of rows and adds a line for every loop. Both snippets yield the same results (which is very weird in my opinion). I also tried ax.hline which yields the same results.

Index unadjusted:

for i in range(0, len(data)+1):
    cells[i, 0]._loc = custom_allignment_first_column
    cells[i, 0].set_text_props(fontproperties= fm.FontProperties(fname=font_location, size=60, weight= "semibold"))
    ax.axhline(y= i, color=font_color_text)

Index adjusted:

for i in range(0, len(data)+1):
    cells[i, 0]._loc = custom_allignment_first_column
    cells[i, 0].set_text_props(fontproperties= fm.FontProperties(fname=font_location, size=60, weight= "semibold"))
    ax.axhline(y= (i * 700000), color=font_color_text)

Many thanks in advance :D

Strijder
  • 46
  • 2

1 Answers1

0

I don't quite understand what you're after here. It might help if you can show some more of your code or an example of what you want the plot to look like. If you have a 2d ndarray cells, then you can plot each row as a different trend line with

import matplotlib.pyplot as plt

rows,columns = cells.shape
for i in range(rows):
    plt.plot(range(columns),cells[:,i])
plt.show()
sjc
  • 1,117
  • 3
  • 19
  • 28