Ask Your Question
0

Align Tables with show

asked 2020-05-31 16:05:49 +0100

Bryan gravatar image

updated 2020-05-31 16:42:42 +0100

I currently have a problem with tables. I want to show them at the right side of the output box. For whatever reason, align does nothing to my table.

To explain exactly my problem, I currently have a Graph G and a Table T. I want them to be displayed one left and the other one, right (so you can extract data from them without scrolling).

This is my current code:

T = table([['a', 'b', 'c'], [1,2,3]])
T.options(align='right')

G = Graph({0:[1,2]})
show(T)
show(G)

Thank you in advance for your time!

EDIT: I'm using the Jupyter notebook

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2020-06-01 19:28:35 +0100

Juanjo gravatar image

The align=right option acts inside the table, not outside. So, to put the graph and the table in parallel, you can use Jupyter widgets. The following code implements this idea:

import ipywidgets as widgets

T = table([['a', 'b', 'c'], [111,222,333],[4,5,6]])
T.options(align='right')
G = Graph({0:[1,2],2:[0,4],3:[1,4],4:[1,0],5:[1,3,4]})

# Define left and right containers where to place output
output_l = widgets.Output(layout={'border': '2px solid blue', 'width': '40%'})
output_r = widgets.Output(layout={'border': '2px solid red', 'width': '40%'})

# Fill left container
with output_l:
    show(G)
# Fill right container
with output_r:
    show(T)

# Show containers
widgets.HBox([output_l,output_r], layout={'justify_content':'space-around'})

This is the result:

image description

Of course, you can modify the properties of each container to meet your needs.

edit flag offensive delete link more

Comments

This is exactly what I needed, thank you a lot!

Bryan gravatar imageBryan ( 2020-06-08 01:40:38 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-05-31 16:05:49 +0100

Seen: 263 times

Last updated: Jun 01 '20