1

I am using plotly offline to create a table.But the output is displayed as a single row,not as shown in the output format given in the following link(i.e not as a table)

https://plot.ly/python/table/#changing-row-and-column-size(“Changing Row and column size”)

Here is the code,

import plotly
import plotly.graph_objs as go
#plotly.offline.init_notebook_mode()
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
values = [[['geneNames', 'uniprotIDs', 'ec-code', 'subcellularLocation', 'tissueSpecificity',
            'proteinName', 'subunit', 'species']], [[' G6PC', ' P35575', ' 3.1.3.9',
            '  Endoplasmic reticulum membrane', 'No Data', ' Glucose-6-phosphatase alpha',
            'No Data', ' Homo sapiens']]]
trace0 = go.Table(
  type = 'table',
  columnorder = [1,2],
  columnwidth = [80,400],
  header = dict(
    values = [['<b>PARAMETERS</b>'],
                  ['<b>VALUES</b>']],
    line = dict(color = '#506784'),
    fill = dict(color = '#119DFF'),
    align = ['left','center'],
    font = dict(color = 'white', size = 12),
    height = 40
  ),
  cells = dict(
    values = values,
    line = dict(color = '#506784'),
    fill = dict(color = ['#25FEFD', 'white']),
    align = ['left', 'center'],
    font = dict(color = '#506784', size = 12),
    height = 30
    ))

data = [trace0]
plot(data)

I would like to ask for some help

EDIT: Would it be possible to save the table in png/txt format?I tried replacing 'uniprot.html' with 'uniprot.png'. But the file gets saved as uniprot.png.html.

5
  • The output table opens as a html file.Instead of manually using the save icon in order to save the file,I wish to save it programmatically. Any suggestions on how this can be done? Commented Dec 3, 2017 at 15:41
  • Try plotly.offline.plot(data, filename='uniprot.html', auto_open=False) Commented Dec 3, 2017 at 15:58
  • Would it be possible to save the table in png/txt format?I tried replacing 'uniprot.html' with 'uniprot.png'. But the file gets saved as uniprot.png.html. Commented Dec 3, 2017 at 16:45
  • Please ask only question at once, otherwise it is difficult for other users to find answers. Commented Dec 3, 2017 at 17:10
  • Thanks.I have added the question to the initial post Commented Dec 4, 2017 at 1:48

2 Answers 2

2

Looks like as if the document and the current version of Plotly are out of sync. Try using a simple of list of two lists (column 1 and column 2).

values = [['geneNames', 'uniprotIDs', 'ec-code', 'subcellularLocation', 'tissueSpecificity', 'proteinName', 'subunit', 'species'], 
          [' G6PC', ' P35575', ' 3.1.3.9', '  Endoplasmic reticulum membrane', 'No Data', ' Glucose-6-phosphatase alpha', 'No Data', ' Homo sapiens']
         ]

enter image description here

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

Comments

0

Regarding your question about saving (figures) as PNG, check out orca. This is the graphing engine which sits behind plotly.

To be honest, it's a little fiddly at first, but easy once you get going, and it provides PNG support!

Comments

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.