Python Forum
Fixed colum width for rowLabels i Matplotlib
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Fixed colum width for rowLabels i Matplotlib
#1
Is there a way to set a min-width or in general width value to the row label cells (r1, r2) in the following code?

import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import textwrap as twp
import sys
import json 
import matplotlib as mpl



fig, ax = plt.subplots();


the_table = plt.table(cellText=['c1','c2'],
                      rowLabels=['r1','r2'],
                      bbox=[0, -0.5, 1, 0.5],
                      colLabels= ['col1', 'col2'],
                      loc='bottom')

table_props=the_table.properties()
  
table_cells=the_table.get_celld()
for cell in table_cells:
    print(cell)
    if cell[1] == -1:
       the_table[cell].set_width(3)



Using set_width does not seem to have any effect.
buran write Jun-10-2023, 06:35 PM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python code to set column width 1418 11 1,408 Jan-20-2024, 07:20 AM
Last Post: Pedroski55
  How to do "fixed size" (wrapping) math in Python? AlexanderWulf 13 1,970 Jul-19-2023, 04:13 PM
Last Post: deanhystad
  Encrypt and decrypt in python using own fixed key SriRajesh 3 5,004 Feb-20-2022, 01:18 PM
Last Post: dboxall123
  width of Unicode character Skaperen 6 2,789 Sep-27-2021, 12:41 AM
Last Post: Skaperen
  image.thumbnail(width, height) not working PCesarano 2 3,479 Apr-08-2021, 06:09 PM
Last Post: PCesarano
  Matplotlib: How do I convert Dates from Excel to use in Matplotlib JaneTan 1 3,279 Mar-11-2021, 10:52 AM
Last Post: buran
  Play fixed frequency sound in python 3 jpezz 2 2,824 Feb-07-2021, 08:21 PM
Last Post: jpezz
  Referencing a fixed cell Mark17 2 2,092 Dec-17-2020, 07:14 PM
Last Post: Mark17
  How can I get the width of a string in Python? aquerci 14 16,310 May-27-2019, 06:00 PM
Last Post: heiner55
  fixed width numbers Skaperen 15 8,775 May-27-2019, 09:42 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020